The #include Command

Managing a complex web site can be a considerable task, particularly if you wish to maintain a common look and feel through out all the pages. Including a common footer or navigation bar to your site helps your visitors identify where they are and helps them move quickly to the information they need. However if you then need to change the footer, you would need to update every page on your site. By using SSI to insert a file at the end of each of your pages you would only need to change one file. The SSI directive include allows us to merge other files into our HTML pages. It is followed by the parameters file or virtual. file specifies a filename relative to the current directory, virtual can specify a relative filename or an absolute URL within the whole document root for the virtual server.

<!--#include virtual="/dir/filename" -->
<!--#include file="filename" -->

Simple Example: Including a footer

A .shtml file:

<html>
<head><title>SSI Test</title></head>
<body>
<p> This is my text from index.shtml </p>
<!--#include virtual="/includes/footer.html"-->
</body>
</html>

The /includes/footer.html file:

Please email <a href="mailto:harry@mycompany.co.uk"> Harry</a> for more details on our products.

Will result in the following output being set to the client:

<html>
<head>
<title>SSI Test</title>
</head>
<body>
<p> This is my text from index.shtml </p>
<p> Please email <a href="mailto:harry@mycompany.co.uk">Harry</a>
for more details on our products.
</body>
</html>
Content Manager [Administrator] 16 December 2005  Permalink  
Download Free Trial

Recent Articles

Other Resources



www.zeus.com