GENUKI Maintainers' Pages
Version 1.21
Server Side Includes (SSI)
SSI (Server Side Includes) are directives that are placed in web pages, and evaluated on the server when the pages are being served to a browser. They allow the dynamic generation of content and its addition to an existing web page. They are sometimes called SHTML fragments because they are invoked by means of the shtml file extension. The main disadvantage is that web pages using SSI cannot be fully tested on a local computer because there is, effectively, no server to execute the SSI directives.
The most frequent use of SSI is to include the contents of one or more files into a web page on a web server. For example, the current service status message could be included in web pages by using:
- <!--#include virtual="../currentservicestatus.txt" -->
By changing only the "currentservicestatus.txt" file, all pages which included the file will display the latest status.
Server Side Includes are also useful for including a common piece of HTML code throughout a site, such as a standard page header, a page footer or a navigation menu. Navigation menus can be conditionally included using control directives. SSI can also be exploited as a simple programming language.
For a web server to recognize an SSI-enabled HTML file and therefore execute the SSI directives, the web page's filename must have the extension shtml.
There are many others, but the following small selection of SSI directives might be useful to GENUKI maintainers:
include file or virtual: Allows the content of one document to be included in another. The parameters specify the file (HTML page, text file, script, etc) to be included. The file parameter defines the included file as relative to the current directory; the virtual parameter defines the included file as relative to the root. E.g.,
<!--#include virtual="header.html"-->echo var: Displays the contents of a specified HTTP environment variable. E.g.,
[<i>Last updated <!--#echo var="LAST_MODIFIED"--> by Maintainer</i>]The following variables might be useful:
- DOCUMENT_NAME: The current filename.
- DOCUMENT_URI: The virtual path to this document.
- DATE_LOCAL: The current date, local time zone.
- DATE_GMT: Same as DATE_LOCAL but in Greenwich mean time.
- LAST_MODIFIED: The last modification date of the current document.
exec cgi: Executes a CGI script and places the output in an HTML page. E.g.,
<!--#exec cgi="/cgi-bin/nearby.cgi?etc" -->
Some examples of the use of SSI in a GENUKI context follow:
<h4><a name=Cemeteries>Cemeteries</a></h4>
<!--#include virtual="/cgi-bin/churchlink?CEM" --><h4><a name=ChurchHistory>Church History</a></h4>
<h4><a name=ChurchRecords>Church Records</a></h4>
<!--#include virtual="/cgi-bin/churchlink" --><h4><a name=Description>Description and Travel</a></h4>
<!--#include virtual="/cgi-bin/piclinkcsi?GR=SD366271,CCC=LAN" --><h4><a name=Maps>Maps</a></h4>
<!--#include virtual="/cgi-bin/maplinkcsi?GR=SD366271,CCC=LAN" -->
Remember, the page source that you see in your browser is that produced by SSI not the original with the special comments. An example of a page using the code fragments above is that of Lytham.
The first two above include details from the church database into the page and the selection is for those entries containing the url of the SSI page, in this case Lytham.
piclinkcsi and maplinkcsi are just csi versions of the piclink and maplink cgi scripts and produce the links within the SSI page itself.