bhakti_thakkar Posted September 8, 2006 Share Posted September 8, 2006 hi all,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 >:(Thanks Bhakti Thakkar Quote Link to comment https://forums.phpfreaks.com/topic/20111-problem-in-template-files/ Share on other sites More sharing options...
HuggieBear Posted September 8, 2006 Share Posted September 8, 2006 Why not use an absolute URL instead of a relative URL?If you put:[code]<img src="http://www.example.com/images/myimage.png" />[/code]instead of something like:[code]<img src="../images/myimage.png" />[/code]It shouldn't matter where the file's located.RegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/20111-problem-in-template-files/#findComment-88322 Share on other sites More sharing options...
bhakti_thakkar Posted September 11, 2006 Author Share Posted September 11, 2006 hi,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 BhaktiThakkar Quote Link to comment https://forums.phpfreaks.com/topic/20111-problem-in-template-files/#findComment-89635 Share on other sites More sharing options...
radalin Posted September 11, 2006 Share Posted September 11, 2006 in your template file do something like: <img src="{PREFIX}/images/myimage.png">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. Quote Link to comment https://forums.phpfreaks.com/topic/20111-problem-in-template-files/#findComment-89685 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.