how do i ensure image paths are correct for php requires that are pulled in as you drill down? if i pull in the same require for the banner on every page, on every level, i lose the image path.
@GenixdeaeAug 14.2005 — #it all depends on where the include is being executed, NOT where the script is located. I was facing this same issue with my cms i'm building. What you have to keep in mind is that you could have that script in folder includes/images/banners/banner_top.php but it it's executed in index.php(in the root of the site) the image path is going to be images/banners/image.xxx where as if its in a folder called messaging/index.php it's going to now be ../images/banners/image.xxx....
Something you could try(as i'm not sure if this would even work, or be a good idea) is something like[code=php]$get_url = explode($_SERVER["DOCUMENT_ROOT"], "/"); $go_back = count($get_url); //count how many folders we are up $img_link = ""; //define the variable first if($go_back != 0 || $go_back != NULL) { //i'm not sure if these are necasary or if doing if(!empty($go_back)) { would work for($i=0;$i<=$go_back;$i++) { $img_link .= $img_link ."../"; $i++; } } $img_link .= $img_link ."link/to/image/from/root.xxx";[/code]Like i said i have no idea if that'll work or not, but it's worth a shot
Edit:::
I just noticed an issue...if you're site is part of a subdomain(eg: hostsite.com/~yousite) you'll always return 1 in the explode...to get around that you can just change the if statement to say[code=php]if($go_back == 1) {[/code] and that'll take care of that issue
@bokehAug 15.2005 — #Blimey! Does he really need all that code? Why cant he just do this: [code=php]require($_SERVER["DOCUMENT_ROOT"].'/path/to/file/filename.ext');[/code] it is even possible to go backwards from root like this: [code=php]require($_SERVER["DOCUMENT_ROOT"].'/../../includes/filename.ext');[/code]
Truth is though, I am confused. He said image paths and those would need to be http paths. Sely can you clarify what you are trying to do?
@GenixdeaeAug 15.2005 — #if i understood him right, he's tring to make a template with images and includes. The only catch is, if you have an included file in %root_dir%/includes/includes.php and in there you have your locations to the images(path/to/image.ext)...if you include that include into a differant directory(such as %root_dir%/applepie) those locations, in the includes file, now need to have a ../ added to the front of them which will now make it so that they wont display in %root_dir% because they have the ../
Now your way will work but that would mean doing that on every page(which defeats the purpose of a template)
i easly could have mis understood what he was looking for tho