Template Site : Basic Page Controller

Now that we have set up a template and extended the Kohana template controller so that we can customize how our web site responds, it is now time to create an actual page controller so that we can start serving web pages.

Our page controller will be called page.php and should be created in the following directory


Click here for the source file

Here is our page controller. It contains two actions, one for loading a home page and another for loading a contact page.

  <?php defined('SYSPATH') or die('No direct script access.');
  class Controller_Page extends Controller_Demo {
  	public function action_home()
  		$this->template->title = __('Welcome To Acme Widgets');
  		$this->template->content = View::factory('page/home' );
  	public function action_contact()
  		$this->template->title = __('Contact Information for Acme Widgets');
  		$this->template->content = View::factory('page/contact' );

Now we have to create view files for our two pages. The files will be call home.php and contact.php and should be created in the following location.


Click here for the source files

Here are two view files you can use. At the moment these are very basic but could be customized to any extent.


  <h1>Welcome to our homepage.</h1>
  <p>We love our new Kohana web site</p>


  <h1>How to contact us.</h1>
  <p>We don't like to be contacted so don't bother.</p>
template-site/basic_page_controller.txt · Last modified: 2009/10/15 01:30 by kerkness