tags:

views:

37

answers:

5

So I have a website and I'm using a basic menu located at the top right corner of the screen. It's links are as follows:

| Home | Blog | Results | Pictures | Our Location |

Form time to time I need to add a new link to the menu or change where one of the links points to. This means that on every page that the menu exist I must manually change the link. Surely there is some way to have a master menu that is just put on every page.

Or am I dreaming?

+2  A: 

Put the menu in a separate file and include it on the server side, either using a full-blown scripting language like PHP (one line) or using SSI.

Max Shawabkeh
I don't know php. Could you provide an example of how to use SSI?
Bob Dylan
There's a SSI example in the linked article (`<!--#include virtual="path/to/menu.htm" --`>) and in PHP it would be: `<?php include 'path/to/menu.htm'; ?>`.
Max Shawabkeh
@Max S.: So I just found out Yahoo Small Business doesn't support `.shtml`. Any other options?
Bob Dylan
I went with the PHP include. I guess it's never to late to learn. ;-)
Bob Dylan
A: 

There are various ways to do this. It depends what you have access to on the server. Possibly the simplest mechanism is server-side includes. You would just have a file that contains the menu and include it on every page.

You can also do this with every programming language in more or less elegant ways.

EDIT: The SSI is quite simple. You can just make a /header.html file, then do:

 <!--#include virtual="/header.html" --> 

in the appropriate place.

Matthew Flaschen
A: 

Have a server side program determine what menus and locations of the links need to be there. Then use ajax to periodically poll the server side script to get the contents of the menu at the current time.

It'd be easy to have it send an xml data back like:

<menu>
    <link name="Home" href="destinationhome.html"/>
...
    <link name="Pictures" href="....html"/>
 </menu>

Then build your links from that data.

Harley Green
A: 

use the PHP include on all your pages

<?php include 'includes/menu.php'; ?>

and have a separate menu.php within a folder named 'includes'. you'll need to save all oyur pages as .php

you can make your footer as an include too

pixeltocode
A: 

You can generate pages from templates before uploading them: See Template Toolkit.

Sinan Ünür