Forum Moderators: coopster

Message Too Old, No Replies

navigation system with includes

         

kumarsena

5:37 pm on Sep 5, 2004 (gmt 0)

10+ Year Member



this is a problem i have had for a while, but isolved it by using the URL for the links.

i got a file with the nav sysyem thta i include into all the other pages. how can i make the links so that they will work whether the nav system is included into pages in root or subfolder or sub sub folders.

ive tried putting it like this "/includes/menu.php"
but doesnt work.

thanks for any help
kumar

noah

5:49 pm on Sep 5, 2004 (gmt 0)

10+ Year Member



If you use absolute links (put the 'http://' at the beginning of your links) then you can include your navigation anywhere with working links. Of course, if you *really* wanted relative links, you could write a script that would adjust the links based on the page url...

Gadnium

5:51 pm on Sep 5, 2004 (gmt 0)

10+ Year Member



<? $nav = "../nav.php";?>
<? include($nav);?>

This will include your nav file and should answer all of your questions.

Within the nav.php file you should always use the full path to the page instead of just the relative path.

[yourdomain.com...]

instead of ../page.php

Hope this helps..

Gadnium

encyclo

6:07 pm on Sep 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can also use a path relative to the document root:

<?php include($_SERVER["DOCUMENT_ROOT"]."/includes/menu.php");?>

For the links in the include file too, you should use only those relative to your document root, such as:

<a href="/path/to/file.html">Link</a>

kumarsena

6:09 pm on Sep 5, 2004 (gmt 0)

10+ Year Member




thanks guys, it was helpful.
appreciated