reports: Fix id of custom date selector
[ninja.git] / system / controllers / template.php
blobfbfdb239556a63ce9d19af8cd91ef30ceba1a88e
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
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
5 * can be overloaded.
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 $
12 * @package Core
13 * @author Kohana Team
14 * @copyright (c) 2007-2008 Kohana Team
15 * @license http://kohanaphp.com/license.html
17 abstract class Template_Controller extends Controller {
19 // Template view name
20 public $template = 'template';
22 // Default to do auto-rendering
23 public $auto_render = TRUE;
25 /**
26 * Template loading and setup routine.
28 public function __construct()
30 parent::__construct();
32 // Load the template
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'));
42 /**
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