1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 * Allows a template to be automatically loaded and displayed. Display can be
4 * dynamically turned off in the controller methods, and the template file
7 * To use it, declare your controller to extend this class:
8 * `class Your_Controller extends Template_Controller`
10 * $Id: template.php 3917 2009-01-21 03:06:22Z zombor $
14 * @copyright (c) 2007-2008 Kohana Team
15 * @license http://kohanaphp.com/license.html
17 abstract class Template_Controller
extends Controller
{
20 public $template = 'template';
22 // Default to do auto-rendering
23 public $auto_render = TRUE;
26 * Template loading and setup routine.
28 public function __construct()
30 parent
::__construct();
33 $this->template
= new View($this->template
);
35 if ($this->auto_render
== TRUE)
37 // Render the template immediately after the controller method
38 Event
::add('system.post_controller', array($this, '_render'));
43 * Render the loaded template.
45 public function _render()
47 if ($this->auto_render
== TRUE)
49 // Render the template when the class is destroyed
50 $this->template
->render(TRUE);
54 } // End Template_Controller