I have this problem using the PEAR ITX templating system (or any other tpl system for that matter). Where do I put the images? Suppose all my TPL files are in a folder called 'tpl' and all the images are in a subfolder of tpl called 'images'. That works just great when i'm editing the tpl files in dreamweaver or viewing them in a browser because my image references are relative references.
HOWEVER, when my PHP files, which are organized in a different folder called 'php', render one of the tpl files, the relative image reference in the tpl file no longer works because the html that results causes a browser to go hunting in the php folder for a subfolder called images.
QUESTION: How does one handle image references (or css or javascript references) in tpl files?
If that is not clear, let me explain. On my server i have a tpl file:
/var/www/html/tpl/index.tpl
it has code that looks like this:
<p>Hello World, here is my image:<br>
<img src="images/my_image.jpg"></p>
the image it refers to (which i have dutifully uploaded to my server) is:
/var/www/html/tpl/images/my_image.jpg
On the other hand, my php file is:
/var/www/html/index.php
which contains this code:
include("HTML/ITX.php");
$tpl = new IntegratedTemplateExtension("tpl/");
$tpl->loadTemplatefile("index.tpl");
$tpl->show();
As you might have surmised, the image references in the html output of index.php are broken because index.php basically just outputs the html above which says images are found here:
/var/www/html/images
Does anyone have a cool way of dealing with this? NOTE: I understand that I could put a symbolic references (i.e, a file system alias) in my folder to point to the other folder, but let's assume my php files have pretty complex folder structure which does not mirror my fairly complex tpl folder structure.