SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    288
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Navigation -- I'm making this too hard

    My issue is how to use the same link paths for my navigation menu in my index.htm that I do for the pages that occupy subordinate directories.

    As I see it, the index.htm must be in the root directory whereas I want my other htm pages in their own subdirectory.

    The hangup I see in doing so is that each navigation link in my index.htm would have to use "directory/page.htm" as the href=, whereas the links from the subdirectory pages will have to be "../directory/page.htm" right?

    Other than redirecting my index.htm to its own subordinate directory or creating a cute php approach, is there a way to create a single navigation excerpt?

    Regards,

    grNadpa

  2. #2
    SitePoint Wizard bronze trophy bluedreamer's Avatar
    Join Date
    Jul 2005
    Location
    Middle England
    Posts
    3,402
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Indeed there is, by putting a / in front of each href the link paths will remnain correct no matter what page you are on, eg

    Code:
    <ul>
    <li>< href="/index.htm"></a></li>
    <li>< href="/directory/index.htm"></a></li>
    <li>< href="/somethingelse/index.htm"></a></li>
    <li>< href="/contact/index.htm"></a></li>
    </ul>
    Or a better way of doing it is to use a directory path approach, if you change index.htm to index.php it will still work...

    Code:
    <ul>
    <li>< href="/"></a></li>
    <li>< href="/directory"></a></li>
    <li>< href="/somethingelse"></a></li>
    <li>< href="/contact"></a></li>
    </ul>

  3. #3
    SitePoint Addict
    Join Date
    Oct 2005
    Posts
    288
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Terrific.

    Just want to confirm that what makes the "better way" work is that all my markup files are named index.htm (or. php) within their directory.

  4. #4
    SitePoint Wizard bronze trophy bluedreamer's Avatar
    Join Date
    Jul 2005
    Location
    Middle England
    Posts
    3,402
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    It means that if at some point you change /directory/index.htm to /directory/index.php you won't have to update the navigation HTML...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •