A Complete Guide to Web Design

(やまだぃちぅ) #1
256 Chapter 13 – Server Side Includes

List of Elements


Web Design in a Nutshell, eMatter Edition

based on specific variables (the “test conditions”). For instance, you could publish
one version of your page for users accessing it with the Netscape browser and
another for Internet Explorer users.
The basic flow elements are:
<!--#if expr="test_condition" -->
<!--#elif expr="test_condition" -->
<!--#else -->
<!--#endif -->
The first command contains theifstatement that causes the server to test for a
condition (e.g., if the browser is Netscape). If it is found to be true, the server
prints the text or executes any SSI commands immediately following theif
command. If the test condition is false, theeliforelsestatements are used to
output specified text or commands. Theendifelement ends theifelement and
is required.
In the following example, a greeting is customized based on the user’s browser:
<!--#if expr="\"$HTTP_USER_AGENT\" = \"Mozilla\"" -->
Welcome Netscape User!
<!--#elif expr="\"$HTTP_USER_AGENT\" = "\"Explorer\"" -->
Welcome Internet Explorer User!
<!--#else -->
Welcome!
<!--#endif -->
As you can see, this is where a little programming knowledge comes in handy for
getting the most out of SSI.

Setting Variables


The standard available environment variables were introduced earlier in this
chapter. XSSI adds the capability to create your own variables using theset
element as follows:
<!--#set var="category" value="help" -->
Your customized variables can then be used as test conditions using the flow
control elements listed earlier.

List of Elements


The following is a list of the primary Server Side Includes and their respective
attributes.

config
config errmsg|sizefmt|timefmt="string"

This controls various aspects of SSI.
Free download pdf