Hello there,
I am, yes, still working on my site redesign. I am planning for it to be done in one week!
However, I decided to go with a templating system. I now have header.php and footer.php, and a seperate script replaces all of the varying variables, such as:
{title}
{randQuote}
{etc}
with the appropriate PHP Variable.
However, my menu is dynamic, with a quite elaborate script. And the way the templating system is set up, I can not simply put an include call in header and/or footer.php.
What I need to do is have a seperate script for the menu, e.g., menu.php. When the templating system finds {menu} in header.php, it needs to replace that call with the output generated by menu.php... do you understand?
I hope I have made it clear enough.
If you do not understand, please state as such and I will do my best to clarify.
- The Monkey
[SOLVED] {template variable} -> include file
Moderator: General Moderators
-
The Monkey
- Forum Contributor
- Posts: 168
- Joined: Tue Mar 09, 2004 9:05 am
- Location: Arkansas, USA
[SOLVED] {template variable} -> include file
Last edited by The Monkey on Fri Jun 25, 2004 12:24 pm, edited 1 time in total.
basically you pass a class an array of the things to be replaced
Code: Select all
$vars = array('TITLE' => 'hi',
'NAME' => 'PrObLeM',
'FOO' => 'BAR!!')
//then
//you parse the variable with the data
foreach ($tags as $tag => $data)
{
$this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
}for menu it would be:
Code: Select all
ob_start();
include 'menu.php';
$menu_txt = ob_get_contents();
ob_end_clean();
$vars = array(
'TITLE' => 'hi',
'NAME' => 'PrObLeM',
'FOO' => 'BAR!!',
'MENU' => $menu_txt
);
//then
//you parse the variable with the data
foreach ($tags as $tag => $data)
{
$this->page = eregi_replace('{' . $tag . '}', $data, $this->page);
}pass the menu to this function:
Code: Select all
function parse($file){
ob_start();
include($file);
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}-
The Monkey
- Forum Contributor
- Posts: 168
- Joined: Tue Mar 09, 2004 9:05 am
- Location: Arkansas, USA