Adil
DevBest CEO
- May 28, 2011
- 1,276
- 714
Basically, I'm working on a CMS, and I need an over-simplified templating system. I've got this so far (from a tutorial):
class.template.php
index.php (calls necessary functions)
What I want to do, is load more than one file, or just use some tools like '#title#' throughout the CMS
Any ideas?
~Adil
class.template.php
PHP:
<?php
class template{
function load($filepath) {
$this->template = file_get_contents($filepath);
}
function replace($var, $content) {
$this->template = str_replace("$var", $content, $this->template);
}
function publish() {
eval("?>".$this->template."<?");
}
}
PHP:
<?
include "Classes/template.class.php";
include "global.php";
$template = new Template;
$template->load("home.html.php");
$template->replace("#title#",$CONFIG['site']['title']);
$template->replace("#description#",$CONFIG['site']['desc']);
$template->publish();
?>
Any ideas?
~Adil