Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how do i create a navbar in one file to be used in several pages?

    Hello all.

    I'm trying to create a navigation menu that will be used across several web pages (all .html files) from a list stored in "navbar.html" and i can't figure out how to either import it or utilize it.

    I have about 30-40 pages that this navigation bar needs to be included on, and it needs to display the same information on each page. Up until now, I embedded the navigation bar into each page. Since I only had to maintain 5 pages, I was able to edit each page easily to make the navbar consistent across each page. Now that the site has grown, I need to be able to edit the navbar in a separate file so that I'm not constantly updating 30-40 pages all the time.

    Is this possible? Can anybody lend me a hand with it?

    Thank you,

    Crock

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    With server side includes:

    <!--#include virtual="includes/MENUFILENAME.shtml" -->

    You can also do it with a server side language, like this (in PHP)

    <?php
    include(MENUFILE);
    ?>

    HTH,
    Dan
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,724
    Thanks
    6
    Thanked 1,013 Times in 986 Posts
    Wow, you must be the third one today to ask this question.
    You could use the object element if you wanna keep it simple and without a server side script involved but it’s not so well supported.

    Server side solutions were provided in this thread.

  • #4
    New Coder
    Join Date
    May 2007
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you can use php, this would be a very good idea, IMO.

    Code:
    <?php
    include ("/path/to/filename/navigation.php");
    ?>
    Otherwise, just copy and paste the coding onto each new page. What I used to do, is I'd take the front page, copy the entire coding to another page and make the nessessary changes. Primitive, I know...

  • #5
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you very much. The PhP thing is EXACTLY what I was looking for. I have since migrated from a .html based web page, to a .php based web page.

    I had forgotten all about using php. Thank you all again.

  • #6
    Regular Coder saeed's Avatar
    Join Date
    Oct 2002
    Location
    West Yorkshire
    Posts
    343
    Thanks
    32
    Thanked 0 Times in 0 Posts
    That can also be done by using JavaScript includes ... copying code everywhere in the website will be a real mess... and if a someone wants to add some new links ... you have to change it everywhere again.

    Search Javascript includes on google.

    ATB...


    Saeed.


    Quote Originally Posted by wicked_ryoko View Post
    If you can use php, this would be a very good idea, IMO.

    Code:
    <?php
    include ("/path/to/filename/navigation.php");
    ?>
    Otherwise, just copy and paste the coding onto each new page. What I used to do, is I'd take the front page, copy the entire coding to another page and make the nessessary changes. Primitive, I know...


  •  

    Posting Permissions

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