Hello, I am building a fairly complicated template system for one of my sites, and so far I am doing fine, I am just having one issue. First, here is the class I use:
class Page
{
var $page;
function Page($template) {
if (file_exists($template))
$this->page = join("", file($template));
else
die("Template file $template not found.");
}
function parse($file) {
ob_start();
include($file);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
function replace_tags($tags = array()) {
if (sizeof($tags) > 0)
foreach ($tags as $tag => $data) {
$data = (file_exists($data)) ? $this->parse($data) : $data;
$this->page = eregi_replace("{" . $tag . "}", $data,
$this->page);
}
else
die("No tags designated for replacement.");
}
function output() {
echo $this->page;
}
}
?>
General tag switch:
$header->replace_tags(array(
'title' => "$title",
'description' => 'Welcome to My eHangout',
'css' => "$style_css"));
$header->output();
My issue is, in my template files, I want to setup a block style. So I can have style info for multiple situations in one file. i.e.:
<- BEGIN USER LOGGED IN ->
Navigation for logged in user here
<- END USER LOGGED IN ->
<- BEGIN USER LOGGED OUT ->
Navigation for logged out user here
<- END USER LOGGED OUT ->
I am not sure how to go about doing that with the class I have. Could someone please explain it to me, or maybe write up some sample code.
Much Appreciated.