Welcome to WebmasterWorld Guest from 54.198.3.15

Forum Moderators: open

Message Too Old, No Replies

Inserting html menu file

How can I have a single file to show up as menu in all pages?

     
11:46 pm on Jul 6, 2007 (gmt 0)

New User

10+ Year Member

joined:July 6, 2007
posts:2
votes: 0


I'm pretty new to using CSS.

Is there a way to create a file that will be a menu that I can modify then import to each page so that I don't have to make modifications to every single page?

Thanks!

Rich

11:57 pm on July 6, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 4, 2002
posts:187
votes: 0


an external style sheet maybe? where you place all the css styles on .css page and then link to the style sheet from each page.
12:01 am on July 7, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 4, 2001
posts: 2260
votes: 54


Rich,

There are several ways, but they all boil down to an "include" page. Includes can be done using editors such as FrontPage and Dreamweaver, or .asp or .php, or .shtml, which ae server side, or webbot include which is user side.

What kind of set up do you have: files extensions and server type?

Marshall

4:20 am on July 7, 2007 (gmt 0)

New User

10+ Year Member

joined:July 6, 2007
posts: 2
votes: 0


I am not exactly sure what you are asking so I'll take a shot..

I am using an external style sheet now. I am on a linux server and am using .html pages.

I can do ssi with my server if that would be the best avenue.

Rich

4:50 am on July 7, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:Sept 4, 2001
posts:2260
votes: 54


emicarn,

You'll have to change you .html extension to .shtml. Where you want the inlcude to appear, place this code:

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

-or-

<!--#include file="exact_path_to_file.html" --> (exact_path_to_file would have to be adjusted for every page)

Be careful though, your links may not and probably won't adjust for file location so all your hyperlinks in the include page should be absolute, not relative. Also, this type of include will include the ENTIRE page, so there is no need for duplicate certain tags in the include page:
Doctype<html><head>meta tags, title, rel links, etc. </head><body></body></html>
In other words, the include page sshould just have the menu, or other content you want to include. Make sesne?

Marshall

10:31 am on July 7, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 4, 2004
posts:887
votes: 1


If you have php you can use this:

<?php
include ($_SERVER['DOCUMENT_ROOT'] . '/somefolder/menu.php');
?>

This will works no matter where the location of the document is that is using the include, e.g if your including it in the file yoursite.com/index.php -or- yoursite.com/somefolder/index.php . Note the file has to have the .php extension that is using the include or you need to set your server to parse html pages as .php If you already have a lot of .html the latter is probably the better choice.

Just my .02 but .php is better because there is so much more you can do with it besides includes, skies the limit for all intents and purposes.