Alright, I'm developing an ultra-lightweight PHP class to parse basic XHTML templates and have hit a snag. Some of my templates include other templates to reduce file-size and repetitive code, as well as allowing things like menus to be modified by editing one single file instead of a menu on every page.
What happens is when my template-parser attempts to replace tags in a sub-template, the page never loads at all. It just completely stops working. I get nothing from the server, even if I wrap every line with "echo" statements.
Here is the function in question:
//Public method to replace all tags on the page with their respective data
public function ReplaceTags($Tags = array())
{
$SubPage = new Page(NULL);
if(sizeof($Tags > 0))
{
foreach($Tags as $Tag => $Data)
{
//$Data = (file_exists($Data)) ? $this->Parse($Data) : $Data;
if(file_exists($Data))
{
if($SubPage->LoadTemplate($Data))
{
if($SubPage->ReplaceTags($Tags))
$Data = $SubPage->OutputBuffer($Data);
else
$Data = "<p>Failed to replace tags in template: " . $Data . "</p>";
}
else
$Data = "<p>Failed to load sub-template: " . $Data . "</p>";
}
$this->TempPage = eregi_replace("{" . $Tag . "}", $Data, $this->TempPage);
}
}
else
return false;
return true;
}
If I comment out the stuff after checking to see whether or not the file exists, everything works except sub-templates don't get parsed and as such, display funky tags instead of data. The class is called "Page".
-
Sephiroth