Forum Moderators: coopster

Message Too Old, No Replies

Dynamic site menu paths

         

CNibbana

2:12 am on Jan 23, 2007 (gmt 0)

10+ Year Member



I created my first PHP dynamic site but have been unable to design the menu stucture such that the nav links remain constant at any level. For example, at the root level when you click on "/page1" the link takes you to the file within the page 1 folder. Since the nav urls are now one level down, clicking on "/page2" will now take you to "/page1/page2" instead of the intended "/page2".

Here are the solutions I have come up with:

OPTION 1: Use "base href" in the head and set it to the main folder. However, it causes links to get odd when you are 4 folders/levels down and you want to link an image as "/image.jpg" but you have to do it as "/level1/level2/level3/level4/image.jpg" because all links originate at your base or root folder.

OPTION 2: Use full urls on all of the nav links (ie. [mysite.com...] [mysite.com...] etc.)

OPTION 3: Put every page in the root folder so they are always relative to the top level nav links, however this gets quite messy with a lot of files.

So how do you guys do it? I am guessing Option 2, but I was wondering if there is a better way?

Thanks!

eelixduppy

4:11 am on Jan 23, 2007 (gmt 0)




For example, at the root level when you click on "/page1" the link takes you to the file within the page 1 folder. Since the nav urls are now one level down, clicking on "/page2" will now take you to "/page1/page2" instead of the intended "/page2".

Are you sure this is the behavior you are getting? This seems correct to me:

/page2
should translate into
http://www.example.com/page2
because the
/
represents the server root. If you omitted the slash THEN you would get the behavior you are describing.

CNibbana

12:01 am on Jan 24, 2007 (gmt 0)

10+ Year Member



LOL It's funny and refreshing that something so simple is the solution I needed.

Indeed I did not have the "/" forward slash before all of the links and that is what was causing my problems.

Thank-you for your help!

[edited by: CNibbana at 12:01 am (utc) on Jan. 24, 2007]