SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using single menu include

    Hello from Sweden

    Ive read this post:
    http://www.sitepoint.com/forums/css-...de-689436.html

    Im trying to rebuild my site with a single include menu file.
    (Im using the technic explained in the post above)
    I'm using body id.

    My menu list looks like this:
    <li id="menu-mall1"><a href="../" > Start </a></li>
    <li id="menu-mall2"><a href="arkivet/"> Bildarkiv </a></li>
    <li id="menu-mall3"><a href="expo/" > Expo </a></li>
    <li id="menu-mall4"><a href="om/" > Om </a></li>
    <li id="menu-mall5"><a href="blogg/" > Blogg </a></li>
    with my start-file at the top of my website and the rest of the contents in different subfolders.

    My problem is - when I'm in another directory than the base, the links to a second directory doesn't work. How can I make this links to work?

    Example: when I click on the menu "expo" from the directory "bildarkiv" the url vill be like this:
    http://localhost:8888/www_nywebb/arkivet/expo/.
    The part "/arkivet/" is to much.
    It must look like this http://localhost:8888/www_nywebb/expo/.

    From the startpage to a directory and back again, everything works fine.

    What can I do to make this to work?
    Any help would be very nice Thanks in a million

    Erland Segrsted

  2. #2
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    From what I gather your 'include file' is inserting the menu as you wanted. However, you have this same (include) menu in all your files - main pages - but they are in different 'sub directories'.

    Therefore when you have the 'include' within another directory it will reference something else (not available) because of the include file URL's have a static value.

    You could make 'absolute links' rather than 'relative links' then it would always reference the correct URI. Or use two or more different includes for each directory. Else possibly use some PHP variables for the URL values.

  3. #3
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Just use absolute links. All your links should look like this...

    /whatever.php

  4. #4
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    Its working!

    Ive made a duplicat of my "menu file".

    So I use two "menu files" - one saved in the same folder as my start page and the second file in my "includes folder".

    Thank you for your help it made my day.
    All the best Erland

  5. #5
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,658
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Good. Bu why not just us absolute links and only have one include to update?

  6. #6
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    To me the problem sounds like you are putting the separate pages each in their own directory -- which IMHO is always a colossal waste of time. Admittedly, I tend to use server side code so every page is routed through a SINGLE index.php, but even on a static site the principle is the same.

    includes should be down-tree, aka nested in subdirectories in the order they call each-other. Pages the user is going to call, as a rule of thumb bad idea to put those in ACTUAL subdirectories.


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
  •