Skip to content

Instantly share code, notes, and snippets.

@aguimaraes
Created December 1, 2009 15:29
Show Gist options
  • Save aguimaraes/246369 to your computer and use it in GitHub Desktop.
Save aguimaraes/246369 to your computer and use it in GitHub Desktop.
<?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