<?php
class template
{
private $template_name;
private $registry;
# vars that will be available globally
private $vars = array();
function __construct($registry)
{
$this->registry = $registry;
}
public function __set($index, $value)
{
$this->vars[$index] = $value;
}
# show the view
function show($name)
{
# view file path
$path = __SITE_PATH . '/views/theme/' . __TEMPLATE_NAME . '/' . $name . '.php';
if (file_exists($path) == false)
{
throw new Exception('Template not found in '. $path);
return false;
}
# Load variables to views
extract ($this->vars);
ob_start();
include ($path);
return ob_end_flush();
/*
// Method Two
foreach ($this->vars as $key => $value)
{
$$key = $value;
}
require ($path);
*/
}
}
?>