Step 1

Enter your contact information.

Step 2

Enter your project information.

Step 3

Choose the PHP programmers you want to hire.

Compare Free PHP Quotes





Country



Kohana 3.1 Wiki Tutorial Routes

*Attention PHP Programmers* - Add A Free Listing! Get more clients.

Win a new Compaq Presario Notebook!

In the original Kohana wiki application the URLs in the views were hardcoded. If we wanted to change the domain name or restructure a route we would need to go through the application and change every single URL.

Thankfully the Kohana Route class comes with a method url() which allows us to generate URLs to routes we have specified in the application. In the first tutorial we defined the following routes in application/bootstrap.php:

Route::set('wiki-edit', 'wiki/<page>/edit')
	->defaults(array(
		'controller'=> 'wiki',
		'action'	=> 'edit_page',
	));

Route::set('wiki-save', 'wiki/<page>/save')
	->defaults(array(
		'controller'=> 'wiki',
		'action'	=> 'save_page',
	));

Route::set('wiki-page', 'wiki/<page>')
	->defaults(array(
		'controller'=> 'wiki',
		'action'	=> 'view_page',
	));

Route::set('default', 'wiki')
	->defaults(array(
		'controller' => 'wiki',
		'action'     => 'view_page',
		'id'		 => 'index',
	));

Before we can generate routes we need to set some configuration options in application/bootstrap.php (line ~82). We need to specify the base_url and index_file attributes in the array passed to Kohana::init(). The application on my local install is located at 127.0.0.1/query7kwiki/index.php, so my Kohana::init() statement would read:

Kohana::init(array(
	'base_url'   => '/query7kwiki/',
	'index_file' => 'index.php'
));

In application/views/edit.php the form action attribute was hardcoded to the value /query7kwiki/index.php/wiki/. That can be replaced by:

<?php echo Route::url('wiki-save', array('page' => $page)); ?>

In application/views/single.php there is a link to the edit that specific page. We can replace the href of the anchor tag with:

<?php echo Route::url('wiki-edit', array('page' => $page)); ?>

In the view application/views/create.php change the href of the create page link to:

<?php echo Route::url('wiki-edit', array('page' => $page)); ?>

The wiki application is now portable and can safely be moved to a different server without functionality breaking.

Source http://query7.com/?p=1655
Mon, 16 May 2011 07:39:43 GMT
Tags: kohana, php, Programming, Tutorials, Web Development,

*Attention PHP Programmers* - Add A Free Listing! Get more clients.


kohana


Kohana 3.1 Wiki Tutorial

In this tutorial you will learn how to create a simple wiki using the PHP framework Kohana version 3.1. Several years ago Siddharta Govindaraj created a screencast

php


Using Proxies with cURL in PHP

If you are new to using PHP and cURL please refer to the PHP cURL tutorial. It covers why you should using cURL (as opposed to file_get_contents) and goes over how to make cURL requests with a custom class.

Developing a blog with CakePHP

If you want to develop a blog from sctrach without using any CMS like WordPress or Drupal, then you’ve come at the right place! In this series, we will understand how to develop a blog using
the CakePHP

A Look at PHP 5.3 Frameworks – Symfony2

Ever since PHP5.3 was released we have seen several new frameworks pop up in the PHP community. In this series of articles we will look at and evaluate some of the next generation PHP frameworks. Today we look at S

Programming


Cussing in Commits: Which Programming Language Inspires the Most Swearing?

As any programmer can tell you, programming will make you swear. But did you know that writing C++ will make you swear considerably more than PHP or Python? Developer Andrew Vos was looking for a weekend project when he decided to grab some one million co

Amazon S3 Storage Now Handles Entire Websites

Cheap, cloud-hosted web servers are a key component of a distributed web. But sometimes you don’t need a server, you just need a cheap way to host your static files, like images and videos. That’s the gap Amazon’s S3 service has long fil

Who Swears the Most? How Foursquare Used Hadoop to Find Out

We told you who swears the most in their code, but what about in the real world? Foursquare, the location check-in service, has used its rather large dataset to graph the “rudest” places in the English-speaking world — Manchester, U.K. t

Members:
Davenport
PourHouse Productions Profile
PourHouse Productions

Full Service Web Design/Development/Hosting Company

Davenport, Iowa US
Zrenjanin
Mirza Delic Profile
Mirza Delic

PHP/MySQL Developer

Zrenjanin, Vojvodina RS
Sacramento
Technicate Solutions, Inc Profile
Technicate Solutions, Inc

Technicate Solutions, Inc. is a fast-growing IT Consulting firm servicing the Sacramento area and beyond. We combine innovative technologies with business savvy to make successful projects happen.

Sacramento, California US
Gilbert
Freddythunder Profile
Freddythunder

Gilbert, Arizona US
Chennai
Anis technologies Profile
Anis technologies

website creator chennai, web development firm chennai, product development in chennai, software developer in chennai, website designer in chennai, portal developing firm chennai SEO and SEM solutions

Chennai, Tamil Nadu IN
Design Leads


PHP Programmers Valid HTML 4.0 Transitional Valid CSS!

A Quick Guide to Using HTML5 Forms

Web forms are everywhere—contact forms, comment forms, sign up forms—these days you̵



Bad Browser, No Donut

The Monkey is back from an extended vacation spent surveying the state of the internet around the wo



Internet Explorer: The Browser You Love to Hate

Microsoft's latest promotional effort for Internet Explorer takes a humorous look at the nerd fury i



JavaScript Slider – TinySlider 2

This full-featured and standalone JavaScript slider is easily configurable and visually customizable



The HTML5 Time Element Is Back and Better Than Ever

The time element was removed from HTML5 last year, but then after developers complained it was rescu



Article Tags
PHP Programmers Articles
Browsers| Web Standards| CSS| firefox| HTML5| Web Basics| Programming| Web Services| Mobile| JavaScript| Web Development| Visual Design| Multimedia| chrome| Google| responsive design| This Week in Web| CSS 3| Opera| Web Apps|
Friends:
Live Help Chat Software
Web Design Quote
Web Design