My Template System
Posted: Mon May 19, 2008 5:28 pm
I have a problem with this template system I made. First let me walk you through it and how it works so I can get to my problem.
First I have a table called templates right with: id, name, body.
in my global file which is the file included into the top of every page I run this code.
I dump all my templates into an array every page. Now when I want to show a template that has php in it I do.
The template name is: test. Here is my display_template function:
For some reason say I have the following code in the test template:
and then a file with this in it:
Some reason I cannot get the $testvar to work with the template. I have tried it with out running the display_template function as well. Any help or suggestions would be really appreciated. Thanks.
First I have a table called templates right with: id, name, body.
in my global file which is the file included into the top of every page I run this code.
Code: Select all
$fetch_templates = $mysql->query("SELECT * FROM ".DBPREFIX."templates ORDER by id ASC");
while ($temp = mysql_fetch_array($fetch_templates,MYSQL_ASSOC)){
$template[$temp['name']] = $temp['body'];
}
Code: Select all
$core->display_template($template['test']);
Code: Select all
public function display_template($v){
global $SDK;
global $mysql;
global $error;
global $ipb;
eval('?'.'>'.$v.'<'.'?');
}
Code: Select all
<? echo $testvar; ?>
Code: Select all
$testvar = "mike";
$core->display_template($template['test']);