SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast daveg7's Avatar
    Join Date
    Oct 2008
    Location
    Berkeley, California, U.S.
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow Duplicate Menu Coding

    I'm thinking of creating a site with many pages. Is there a good way to create and edit the menu in just one place, so that it can look the same on all pages?

    (I don't want to change the menu on every page if I can avoid it.)

  2. #2
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,025
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    You can use a separate file and use SSI (Server side includes) or a scripting language to add it to every page automatically.

  3. #3
    SitePoint Enthusiast daveg7's Avatar
    Join Date
    Oct 2008
    Location
    Berkeley, California, U.S.
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Arrow

    Thanks, Molona!

    This looks like a very interesting answer, but I'd like any thoughts about the following before I try to apply these techniques.

    1. Will they work OK with CSS?

    2. Are there any situations where they won't work?

    3. Any other disadvantages?

    Thanks!

    Quote Originally Posted by molona View Post
    You can use a separate file and use SSI (Server side includes) or a scripting language to add it to every page automatically.

  4. #4
    #titanic {float:none} silver trophy
    molona's Avatar
    Join Date
    Feb 2005
    Location
    from Madrid to Heaven
    Posts
    8,025
    Mentioned
    211 Post(s)
    Tagged
    1 Thread(s)
    1 - Yes, it works perfectly

    2- If your hosting company doesn't accept SSI or your hosting plan doesn't allow you to use a script languages (yes, there basic hosting packages that don't allow you to personalize the code)

    3 - No, right now, I can't think of any.

  5. #5
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,675
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I use a basic php include with my bigger sites.

    Create a separate page with no tags and paste something like this:
    Code HTML4Strict:
    <h2>contents</h2>
    <ul class="sub-nav">
    <li>12/06/08 - <a href="http://www.example.com/test/2008-06-12" title="test 1">test 1</a></li>
    <li>12/07/08 - <a href="http://www.example.com/test/2008-06-12" title="test 2">test 2</a></li>
    <li>12/08/08 - <a href="http://www.example.com/test/2008-06-12" title="test 3">test 3</a></li>
    </ul>
    save it as nav.inc.php

    Then simply paste
    Code PHP:
    <?php include ('includes/nav.inc.php'); ?>
    onto your template or whatever pages you need your navigation on. Then once you up date your nav.inc.php every page will be updated.

    The more you learn.... the more you learn there is more to learn.


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
  •