Home |
News (Page 1) |
Web Page Creation Tips, Tricks and Techniques
Using SSI (Server Side Include) Files
Easy way to manage repetitous blocks of HTML.
by Randy Harris office@lexipixel.com
July 21, 2004 (01:47:08 EST)
An SSI, (Server Side Include), file is simply a block of HTML saved as file or created dynamicaly by a script or other programming technique.
Here we'll look at the simplest form of using SSI.
Let's say you have a common block of text that appears on several or all pages on your site. Maybe you want to create a consitent copyright notice and small group of links to your home page, site map, and contact information at the bottom of every page...
You could cut and paste the block of text into every page... but then if you want to change something, (even if it's just changing the year from ©2004 to ©2005), you would need to open every page then search for and replace all of the copyright years --- or you could have used SSI in the first place and created the footer for every page on your site with one small include file.
Here's a quick example, then we'll look at other uses for SSI.
You want the following at the bottom of every page-
Copyright ©2004 My Company Name, Inc., all rights reserved. [Home | Site Map | Contact Us ]
parsed and it's contents inserted into the calling page by the server at the time that page is served.
Example:
Contents of "footer.html" is:
<CENTER> <B>This is the footer I want included in all files</B> </CENTER>
One or more pages contains the directive:
<!--#include file="footer.html"-->
And you change the contents of footer.html to-
<CENTER> <B>This is at the bottom of all pages.</B> </CENTER>
Then the include directive (contained in one or many pages)has not changed and you only need to upload a copy of "footer.html" to the server and the site is updated.
(written and posted by lexipixel, (Randy Harris), to webmasterworld.com)
|
|