Ik heb een simpele template parsen gezocht op internet en deze gevonden;
template_class.php;
PHP
class template
{
var $templatecontent;
var $templatefile;
function parser($file)
{
$this->templatefile = $file;
$this->templatecontent = file_get_contents($this->templatefile) or die("error");
}
function assign($block, $content)
{
$block = '[' . $block . ']';
$this->templatecontent = str_replace($block, $content, $this->templatecontent);
}
function output()
{
echo $this->templatecontent;
}
}
Toon Meer
Me index
index.php;
PHP
include_once("class/template_class.php");
$tpl = new template();
$tpl->parser("template/index.tpl");
$tpl->assign("title", "xxxx");
$tpl->assign("content", "welcome");
$tpl->output();
De index.tpl
index.tpl;
Kan ik nou php in de index.tpl zetten, als het niet zou kunnen waar & hoe dan?
Gr.
Youri