Forum Moderators: not2easy

Message Too Old, No Replies

Navigation bar

Updating navbar globally

         

wghoffma

11:41 pm on Apr 5, 2005 (gmt 0)

10+ Year Member



I am new to CSS and in the process of changing my website to CSS. Is there a way to add/delete items in the navigaton bar and have it change on all pages?

KrazyKid

1:31 am on Apr 6, 2005 (gmt 0)

10+ Year Member



yes, but not with css (that i know of). you'd have to use some very simple php. first create a file called navigation.inc or whatever, then put the content of your navigation bar in there. then on each page put
<?php
include "navigation.inc";
?>
where you want the navigation bar to show up. Also, if the page is in a subfolder, and navigation is in your main folder. you'd go
<?php
include "../navigation.inc";
?>
if it was 2 subfolders down, you'd go
<?php
include "../../navigation.inc";
?>
if you don't know what i mean, experiment! good luck, hope i've helped

wghoffma

1:51 am on Apr 6, 2005 (gmt 0)

10+ Year Member



Thanks alot. I may be back with more questions later.

KrazyKid

5:38 pm on Apr 6, 2005 (gmt 0)

10+ Year Member



no problem. oh, one thing i forgot though...you'll need to change the file extension on all of your files from .htm or .html or whatever to .php. besides that, do everything normally. :)

Span

9:42 pm on Apr 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you don't want yo change your page extensions and your site is on an Apache server and you're allowed to use an .htaccess you could put one in the root (where your index.html is) with this line in it:

AddType application/x-httpd-php .html

Or, if you don't want to use PHP you could use Apache's Server Side Includes.
Put your navigation in a separate file, save it as something like 'navigation.html' and put this tag in your page:

<!--#include virtual="navigation.html" -->

You may need an .htaccess again to make this work without changing your page extension to .shtml.
On Apache 1.3 you would need this line:

AddHandler server-parsed .html

and on Apache 2:

AddOutputFilter INCLUDES .html