okay i have this template class.
PHP Code:<?php
class Page
{
var $page;
function Page($tpl_file = "testy.php") {
$template = "$tpl_file";
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;
}
}
?>PHP Code:require_once("lib/parser.php");
$page = new Page("templates/test/index.body.php");
$page->replace_tags(array(
"title" => "HOME",
"added_by" => "$row[author]",
"added_on" => "$row[date]",
"begin_cat_row" => "?????",
"end_cat_row" => "????"
));
$page->output();
how. would i be able to 'loop' JUSTPHP Code:<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">Title</th>
<th scope="col"> Added on</th>
<th scope="col">Added by</th>
</tr>
<!--- {begin_cat_row}-->
<tr>
<th scope="col">{title}</th>
<th scope="col">{added_on}</th>
<th scope="col">{added_by}</th>
</tr>
<!--- {end_cat_row}-->
</table>
This would save a hell of a lot of time .... n skinning and in coding.PHP Code:<!--- {begin_cat_row}-->
<tr>
<th scope="col">{title}</th>
<th scope="col">{added_on}</th>
<th scope="col">{added_by}</th>
</tr>
<!--- {end_cat_row}-->
Tho if anyone found a better example for this... plz tell me.




Reply With Quote