<?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;
}
}
?>
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(); <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>
how. would i be able to 'loop' JUST this part {{{
<!--- {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}-->
}}}If anyone can find me sumtin better to use(and show me an example of wut im trying to do) plz ... for the LOVE OF GOD. tell me...lol...
Edited by PlaGuEX, 16 September 2005 - 03:35 AM.
