Re: OT--HTML coding question

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Graham
Date:  
To: Main PLUG discussion list
Subject: Re: OT--HTML coding question
From: Mark Jarvis <>
> I have a web site with a large number of hand coded pages. I have a
> block of code that needs to be inserted into each page. The problem is
> that the block will change occasionally as new material is added.
> Obviously, things would be much simpler if I could make the change in
> one place and have each page attach/include/link to/etc. a file
> containing that piece of code. If there is an HTML construct that allows
> that, I haven't found it.


It's called "server-side includes", and it's relatively standard if you're
using Apache. You have to have the directory you want to have server-side
includes enabled in with a config stanza kind of like so:

<Directory "/var/www/localhost/htdocs">
Options Indexes FollowSymLinks Includes
</Directory>
# note that Includes is the option you want to have enabled for this dir.
# that's the docroot of my webhost; modify for your setup
# make sure to restart apache if you change the config file

Once this has been done, all you have to do is to put a construct like so into
foobar.html:

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

...this tells apache that when it's reading foobar.html, it should read the
file /var/www/localhost/htdocs/incs/nav.html and insert that file's contents
into foobar.html at that point, before sending stuff to the client.[0] This
is *really* useful. At work, we basically depend on apache SSI to do 5 tons
of stuff, since many pages use the same stuff across the whole site for
navigation/menu bars/whatever.

If this didn't make any sense, holler.

[0] It can get a bit more complex than that, what with RewriteRules and other
stuff, but that'll get you started.

--
Matt G / Dances With Crows
The Crow202 Blog: http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see

---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss