...

View Full Version : how do i create a navbar in one file to be used in several pages?



crock
06-01-2007, 02:40 AM
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

whizard
06-01-2007, 02:44 AM
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

VIPStephan
06-01-2007, 02:45 AM
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 (http://codingforums.com/showthread.php?t=115317).

wicked_ryoko
06-01-2007, 02:47 AM
If you can use php, this would be a very good idea, IMO.



<?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...

crock
06-01-2007, 04:10 AM
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.

saeed
06-01-2007, 01:49 PM
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.



If you can use php, this would be a very good idea, IMO.



<?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...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum