Snippet: For templates
Posted in general - July 15, 2008

Well been pretty busy with writing the CMS, heres a small code snippet refering to the previous post. I've written up a full templating class but I will show that off layer.

<code>
<?php
if($content['type'] == 'logical'){
// Gathers the executed php file's output into a variable
ob_start();
if(@eval('?>'.$content['body']) === FALSE){
echo"There was a problem parsing the logical content: " . $content['path'].':'.$content['id'];
exit;
}
$content_data = ob_get_clean();

}
elseif($content['type'] == 'simple'){
// Gathers the content text and runs it as a HEREDOC variable.
if(@eval("\$content_data = <<<TEMPLATE\n".$content['body']."\nTEMPLATE;\n") === FALSE){
echo"There was a problem parsing the simple content: " . $content['path'].':'.$content['id'];
exit;
}
}
?>
</code>

Posted By YouDon'tMeanMuch at 8:01 pm


Comment on this post

  Name:
  E-Mail:
  Website:
  Comment: