thesavior
03-20-2007, 02:24 AM
Okay, the title is confusing, but it is probobly something simple. Here is my class:
class tpl_parse
{
public $tplname; // What template to use
public $pagename; //What page to load
public $tpl; //Stores template info.
public $variable = array();
function run()
{
$tpl = file_get_contents(ROOT_PATH."themes/".$this->tplname."/templates/pages/".$this->pagename.".tpl");
preg_match("/{(.*)\:(.*)\:\}/", $tpl, $this->variable); // Search for variables
$this->variable[1]($this->variable[2]);
}
function file_include($tplfile)
{
$pos = strpos($file, "..");
if ($pos === false)
{
require(ROOT_PATH."templates/".$tplfile.".tpl");
}
else
{
echo "You cant do that!";
}
}
}
print_r of $this->variable is:
Array (
[0] => {file_include:header:}
[1] => file_include
[2] => header
)
The line: $this->variable[1]($this->variable[2]);
is giving me the error:
Fatal error: Call to undefined function file_include() in /mounted-storage/home45c/sub001/sc21473-GRUR/dev/forum/includes/functions/tpl_parse.php on line 35
As a note, tpl_parse is a class included and initialized in another class "superclass"
So to define $tplname i do: $superclass->tpl->tplname = "default";
Does anyone have any idea how I make the function in tpl_parse be used?
class tpl_parse
{
public $tplname; // What template to use
public $pagename; //What page to load
public $tpl; //Stores template info.
public $variable = array();
function run()
{
$tpl = file_get_contents(ROOT_PATH."themes/".$this->tplname."/templates/pages/".$this->pagename.".tpl");
preg_match("/{(.*)\:(.*)\:\}/", $tpl, $this->variable); // Search for variables
$this->variable[1]($this->variable[2]);
}
function file_include($tplfile)
{
$pos = strpos($file, "..");
if ($pos === false)
{
require(ROOT_PATH."templates/".$tplfile.".tpl");
}
else
{
echo "You cant do that!";
}
}
}
print_r of $this->variable is:
Array (
[0] => {file_include:header:}
[1] => file_include
[2] => header
)
The line: $this->variable[1]($this->variable[2]);
is giving me the error:
Fatal error: Call to undefined function file_include() in /mounted-storage/home45c/sub001/sc21473-GRUR/dev/forum/includes/functions/tpl_parse.php on line 35
As a note, tpl_parse is a class included and initialized in another class "superclass"
So to define $tplname i do: $superclass->tpl->tplname = "default";
Does anyone have any idea how I make the function in tpl_parse be used?