[SOLVED] Includes: navigation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Includes: navigation

Post by dstefani »

If you wanted to include navigation code in multiple web pages, that would be used by pages on the site root as well as subdirectories, how would you make the image links resolve from anywhere?

Would you use absolute URL's?
Or is there a better way?

Thanks,

dstefani :?:
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

frames

Post by phpScott »

use a frame set
'quicklly ducks for cover under desk and awaits the beating that he knows is coming':lol:
Absolute URL's would work but it would be slower.
carfully lay out your file system?
use PHP to dynamically create the links depending on how far down the directory structure you need to go.

'ducks agian to avoid the coffee mug being thrown at him'
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

I was thinking about using a $GLOBALS var that holds the site root in a config file, then dynamiclly build my links.
<img src="<?=$GLOBALS['site_root'] ?>/assets/images/pic.gif">

Are these the dangerous globals I've heard about?


thanks,

dstefani
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Or define a constant:

Code: Select all

define('SITE_ROOT', 'absolute/path/to/site/root/');
Last edited by McGruff on Sun Aug 07, 2005 9:16 pm, edited 1 time in total.
User avatar
dstefani
Forum Contributor
Posts: 140
Joined: Sat Jan 11, 2003 9:34 am
Location: Meridian Idaho, USA

Post by dstefani »

Yes, sleep deprivation.

That's exactly what I did.
worked out great

Thanks,

dstefani
Post Reply