Jondor
07-06-2006, 08:11 AM
Hi,
Being a programmer type of guy, the first thing I missed when starting to work on my own templates was a way to include files. In the simple templates f.e. every template has the same navigation code, but a change has to be made 3 times. Not good..
So after trying it through an addon (which doesn't work as addons are the last thing handled so included tags were ignored) I added this code to the index.php:
// Handle includes before anything else.
// Gerhard Hoogterp 6 july 2006
$templates="./templates/".$cfgrow['template']."/";
while(ereg("<INCLUDE ([^>\ ]*)[\ ]*>",$tpl,$incl))
{
if (file_exists($templates.$incl[1])) $add="<!-- start include -->\n".implode(" ",@file($templates.$incl[1]))."\n<!-- stop include -->\n";
else $add="<!-- file ".$templates.$incl[1]."doesn't exists! -->";
$tpl=str_replace($incl[0],$add,$tpl);
}
It should go directly after loading the template. In my version 1.5RC2 this is after line 165. (is there a cvs or svn repository for pp?)
After adding this code one can use <INCLUDE nav_include.html> tags in the templates which, in this case, will look for nav_include.html to include. This file should be in the same directory as the other templates.
Comments and suggestions are welcome,
Gerhard
Being a programmer type of guy, the first thing I missed when starting to work on my own templates was a way to include files. In the simple templates f.e. every template has the same navigation code, but a change has to be made 3 times. Not good..
So after trying it through an addon (which doesn't work as addons are the last thing handled so included tags were ignored) I added this code to the index.php:
// Handle includes before anything else.
// Gerhard Hoogterp 6 july 2006
$templates="./templates/".$cfgrow['template']."/";
while(ereg("<INCLUDE ([^>\ ]*)[\ ]*>",$tpl,$incl))
{
if (file_exists($templates.$incl[1])) $add="<!-- start include -->\n".implode(" ",@file($templates.$incl[1]))."\n<!-- stop include -->\n";
else $add="<!-- file ".$templates.$incl[1]."doesn't exists! -->";
$tpl=str_replace($incl[0],$add,$tpl);
}
It should go directly after loading the template. In my version 1.5RC2 this is after line 165. (is there a cvs or svn repository for pp?)
After adding this code one can use <INCLUDE nav_include.html> tags in the templates which, in this case, will look for nav_include.html to include. This file should be in the same directory as the other templates.
Comments and suggestions are welcome,
Gerhard