PDA

View Full Version : INCLUDE xx tag


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

GeoS
07-06-2006, 05:39 PM
I will only write this:
// Added ability to use header and footers for templates. They are not needed but used if included in the template
if(file_exists("templates/".$cfgrow['template']."/header.html"))
$header = file_get_contents("templates/".$cfgrow['template']."/header.html");
if(file_exists("templates/".$cfgrow['template']."/footer.html"))
$footer = file_get_contents("templates/".$cfgrow['template']."/footer.html");

raminia
07-07-2006, 06:19 AM
As I underestood, header.html and footer.html should do what you want without modifications.

Jondor
07-07-2006, 01:27 PM
As I underestood, header.html and footer.html should do what you want without modifications.

Not really.. They are special cases of a general include. In some cases good enough, in others not.

virgohippy
07-15-2006, 08:37 PM
I haven't had any problems replacing <INCLUDED_FILE> with $included_file the way GeoS indicated. My only complaint is that <PIXEL_POST_TAGS> don't work inside the <INCLUDED_FILE>. :)

GeoS
07-15-2006, 10:53 PM
We must rewrite whole Pixelpost and make there an order. Right now there are some ideas but in colision with other :/