tutorial can be found at (http://anantgarg.com/2009/03/13/write-y ... rk-part-1/).
This has it setup to have a template setup for the views and or default controller... Im trying to setup a master template that would surround all of that?
The code is as follows for template.class.php:
Code: Select all
<?php
class Template {
protected $variables = array();
protected $_controller;
protected $_action;
function __construct($controller,$action) {
$this->_controller = $controller;
$this->_action = $action;
}
/** Set Variables **/
function set($name,$value) {
$this->variables[$name] = $value;
}
/** Display Template **/
function render() {
extract($this->variables);
if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php')) {
include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'header.php');
} else {
include (ROOT . DS . 'application' . DS . 'views' . DS . 'header.php');
}
include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . $this->_action . '.php');
if (file_exists(ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php')) {
include (ROOT . DS . 'application' . DS . 'views' . DS . $this->_controller . DS . 'footer.php');
} else {
include (ROOT . DS . 'application' . DS . 'views' . DS . 'footer.php');
}
}
}
Thanks!