Created
December 1, 2009 15:29
-
-
Save aguimaraes/246369 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') OR die('No direct access allowed.'); | |
abstract class Template_Controller extends Controller { | |
// View to be used with template | |
public $template = 'template/base'; | |
// Template will be loaded in the end of controller | |
public $auto_render = TRUE; | |
/** | |
* Load template | |
* | |
* @return void | |
*/ | |
public function __construct() { | |
parent::__construct(); | |
if ( $this->template !== FALSE ) { | |
$this->template = new View( $this->template ); | |
} | |
if ( $this->auto_render === TRUE ) { | |
Event::add('system.post_controller', array($this, '_render')); | |
} | |
} | |
/** | |
* Render the loaded template | |
* | |
* @return void | |
*/ | |
public function _render() { | |
if ( $this->auto_render === TRUE ) { | |
$this->template->render( TRUE ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment