problem in template files
Posted 08 September 2006 - 11:47 AM
i have created a template.tpl.php file in a folder in my project folder. this is basically a file which will hold my images etc and load them. i also have a image folder which has all my project images.i want to set the path of images in template file in such a way that whether i call that file from same directory or from any other folder, the images should load properly instead of path problem. the problem now is if i access it from some directory the images load properly but as soon as change the folder hierarchy there is display problem. to avoid this i was sending a querystring for the image path.but that is not a solution i feel.
PLEASE DO GUIDE ME IN THIS
Posted 08 September 2006 - 12:46 PM
If you put:
<img src="http://www.example.com/images/myimage.png" />
instead of something like:
<img src="../images/myimage.png" />
It shouldn't matter where the file's located.
Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools
Posted 11 September 2006 - 05:06 AM
i had already coded the way you had suggested but i m facing the problem. is there any way through which i can find out the base folder path in a variable so that i can store it in a variable and then i can dyamically pass the href variable to the image tag i.e something like this:
<img src='<?=$ImagePath?>'> ???
I had already tried through $_SERVER['PHP_SELF'].But the problem is i am using 4.0.6 and this works only with 4.3.0 and above. Is there any alternative for $_SERVER['PHP_SELF']
Thanks in anticipation
Posted 11 September 2006 - 08:06 AM
then while you set your tpl file and define your variables, set prefix as you want. define it as .. or templates/mytemplate or any other thing. It should solve your problem. And you can define it as a relative path and there wont be any problems according to the domain name.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users