Fixed Header with Html Editor 2008 -...

User 456632 Photo


Registered User
2 posts

Suppose I have 35 web pages with the same header.

Then I decide changing the header.

Do I have to change my 35 web pages?

Is it possible to build some kind of fixed header (no frames please).

Someone told me there is a kind of INCLUDE function wich let me include my header.html in every page. So if a change header.html, every page is updated.

Can you give me an example of how to do this?

Thanks !
User 355448 Photo


Ambassador
3,144 posts

rlaria,

You may want to click on profile and change your forum name to something other than your email address to help keep spammers away.

What I do is create the code I want for the "header" and to keep from confusing it with the <head> of the page, I call it a mast (as in the masthead of a newspaper). I then have a file named mast.php, and I name my home page index.php.

In my mast.php, I have all the code for the top of my pages and it will include just that code, without any other code. There is no <html>, <head>, or <body> tags. I have <h1>, <p>, <img> and sometimes other tags.

Then in my index.php page, whereever I want my mast to appear, I insert this code:

<div id="mast">
<?php include($DOCUMENT_ROOT . "mast.php"); ?>
</div>

I use the div tag with the id mast for any styling I need to do using CSS.

I also use this for the footer of my page, and even for the meta tags that are constant across all my pages.

This will only work if your server has PHP installed. If you do not have PHP installed, you will need to use something else, and I am not familiar with that.

Hope this helps.
User 463058 Photo


Ambassador
1,073 posts

If you don't have PHP on your server, you can just use regular Server Side Includes (SSI) which look like one of these:

<!--#include file="mast.html"-->

or

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

In this example I used .html but just like Bill's example the mast.html isn't a complete html page. It's only the portion of the code that's needed to fill the hole in the main page. The main page itself which needs the include should be named with .shtml instead of .html or .htm

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.