Web Hosting Talk







View Full Version : Universal element question


brady_44
09-16-2005, 02:14 AM
If I want to have a universal element on a nav bar on my website, where I update one file and it updates all pages, how do I go about doing that? Would I need to create a template file and turn on SSI? Does it require creating a .htaccess file? I just want to be able to update one part of my nav bar and have it effect all of my .html pages. Thanks in advance for any replies.

Alex Fernandez
09-16-2005, 06:58 AM
make the navbar a php include (if possible), or make it generated from a db.

Kepplar
09-16-2005, 09:43 AM
PHP is a pretty stupid waste of resources if you ask me.

Providing Apache has been set to throw shtml (or html) extentions via the SSI preprocessor you can easily include a file into the page. The main files however will have to be named with the extentions.

You can do it yourself though via .htaccess with the following lines:

Options Indexes FollowSymLinks Includes
AddType text/x-server-parsed-html .html


And in the file where you want the menu to appear place a line like this:

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


I've not played round with it, but I think XSLT may be able to do this too. Either option is better than PHP for a static menu.

brady_44
09-16-2005, 09:29 PM
Okay so I would create the .htaccess with those lines and then just create a file with the info I want on all pages. Then I need to rename all my html pages shtml and include <!include ...>. Is that correct?

NyteOwl
09-17-2005, 05:57 PM
If you use

AddType text/x-server-parsed-html .html

the server will parse ALL html pages, not just .shtml so there would be no need to rename any files.

There is a small performance hit when parsing html files but it is usually negligible.