How do I include a file using ServerSide Includes?
You need to have the main file index.shtml in the shtml extension. Then on the files you include you don't need the <html><body> tags. The Menu file can be any extension you want, but normally .txt, but can be .php or .htm/,html/.shtml.
For example: index.shtml
<html>
<head>
<title>SSI Example</title>
</head>
<body>
<!--#include virtual="header.txt" -->
<p> Information about the website.</p>
<p> <!--#include virtual="footer.txt" --> </p>
</body>
</html> header.txt
<img src="header.jpg" alt="Header Image" width="595" height="74" />
<br>
<a href="index.shtml">Home</a> | <a href="example.shtml">Example Page</a> | <a href="header.txt">View Header</a> | <a href="footer.txt">View Footer</a> footer.txt
<hr>
<img src="utchome.gif" width="75" height="79" align="top"> <em>Footer Information. Last modified:date here</em>
Hopefully this example helps you understand how SSI works. Although .txt is one of the most common methods, .php is the most recommended.
The syntax for a PHP include is:
<? include('/directory/file.php'); ?>
You will need to have .php as your page extension.
For example: index.php
<html>
<head>
<title>SSI Example</title>
</head>
<body>
<? include('/directory/header.php'); ?>
<p> Information about the website.</p>
<p> <? include('/directory/footer.php'); ?> </p>
</body>
</html>
You can include files with .php, .html, .txt and other extension.
The final page must have a .php extension.
Again, you should strip out everything except the actual content you wish to include.
Good luck,
Geoserv.
|