i have done something similar to what i think you want in a CMS i am building myself, the way I have done it is in a config.php included on every page i set the template/scheme I want to use for example;
$config['template'] = '1';
$config['scheme'] = 'blue';
The templates are stored in a folder, templates/<template> and images in images/<template> any images which are scheme specific (asin they are for blue/red/yellow scheme etc) will be in images/<template>/<scheme>
Now, for the templating I have template.php which has all my classes in. (at college at the moment so cant paste any snips but ill try and remember as best i can 🙂)
class page {
// setting up the vars
var $page_name;
var $page_template;
var $page_title;
var $page_html;
function page($name, $title, $template="template") {
// default template = template
$this->page_name = $name;
$this->page_title = $title;
$this->page_template = $template;
}
function show($content) {
// this is where output the $content inside the template wrapper
$this->page_html = implode("", dir_to.$this->page_template.".html");
// some str_replace for scheme variable in templates etc
$this->page_html = str_replace("{\$scheme\$}", $config['scheme'], $this->page_html);
// now i echo the page
echo $this->page_html;
}
}
i have a 2nd class for for templates now.
class templates {
// do the var stuff here
function templates($template) {
// set template var to $template
// template html = implode("", templatefile.html);
}
function variable($variable, $replace) {
// do a str_replace in the template html for {$$variable$} and replace with $replace
}
function show() {
return $html
}
}
// now for an example of how i use it
$page = new page("name", "title");
$template = new templates("templatename");
$variable = // database result for example
$template->variable("something", $variable);
$html = $template->show();
$page->show($html);
it might be a bad example, but i hope you kind of understood it 🙂
ill paste the actual class file i have and example usage later if i remember.