WebSTAR 4 Manual & Technical Reference

Manual Contents | Chapter Contents | Previous Page | Next Page

Using WebSTAR SSI Commands

The commands used by the WebSTAR SSI Plug-In take the form of HTML comments, which look like this:

 

<!-- this is a comment. -->

These comments do not show up in the browser, so a line like this:

 

Welcome to my site!<BR> <!-- Kilroy was here -->

will just appear in the browser as:

 

Welcome to my site!

Similarly, an SSI command is replaced with data or otherwise changed by WebSTAR SSI before being sent to the browser, so a line like this:

 

Today's date is <!--#echo var="date_local"-->

will appear in the browser as:

 

Today's date is 1997/12/25:01:01:57

WebSTAR SSI recognizes the #echo command and replaces it with the correct value before sending the page back to the browser. In this case, this command will always display the current local date and time whenever the page containing this line is requested by a browser.

You can also change the format of the date and time to something easier to read, by using the #config command: see TimeFmt Tag .

SSI Command Structure

The general format for SSI commands is a command followed by a tag="value" pair, like this:

 

<!--#command tag="value"-->

and you must have at least one tag="value" pair in each command.

Examples include:

 

<!--#echo var="date_local"-->

which shows today's date,

 

<!--#include virtual="/header.txt"-->

which includes the contents of a file in the host root folder named " header.txt ",

 

<!--#counter var="mycounter"-->

which increments a Counter Value .

If you enter an unrecognized command, it's treated as an #exec piservice command. For more information, see PIService Tag .

Multiple Tags

Some SSI commands can include more than one tag, for example:

 

<!--#counter var="main_page_counter" display="true"-->

Here, the #counter command tells WebSTAR SSI to increment a counter variable, and the var tag tells it which counter ( "main_page_counter" ). Then the display tag tells it to set the display to " true" , so this counter will appear in the page returned to the browser.

Special Characters in SSI Commands

Values used in tag="value" need to be surrounded by double-quote marks ("). WebSTAR SSI will automatically URL-encode anything within the double quotes, so you don't have to worry about spaces or Macintosh special characters. To use a value that has a double-quote as part of it, you can either use the URL encoding for it ( Charles %22Rusty%22 Rahm ) or double the quote ( Charles ""Rusty"" Rham ).The same applies to single-quotes (').

SSI commands are not case sensitive: they treat upper and lowercase letters as being equivalent. This does not apply to field descriptors such as those for the TimeFmt Tag .

WebSTAR SSI is very flexible about spaces in commands: you can have as many as you like between the opening and closing comment marks and the actual command, though you must have at least one space before a tag. For example:

 

<!-- #command tag1 = "value1" tag2="value2" -->

is fine, while

 

<!-- #commandtag1 = "value1"tag2 = "value2" -->

is not, because there is no space before either of the two tags.

SSI Path Names: Virtual and File Paths

Several SSI commands, (the Include Command , FSize Command , FLastMod Command , and others), use paths to specific files on your hard drive. You can express these paths either using the tag virtual as paths using the URL-style paths or with the file tag using Macintosh paths.

Virtual Paths

With the virtual tag, you can use paths like those in HTML links, with forward slashes (" / ") to separate folder names. If the path begins with a slash, the absolute path will start at the host root folder, while if there is no slash at the beginning, the path is relative to the current file.

Neither of these path formats allows you to use a Unix-style double period (' .. ') to go up one folder.

For example,

 

<!--#include virtual="/includes/navbar.inc"-->

will look for a file named navbar.inc inside a folder named includes in the host root folder. It is an absolute path.

The path in this command:

 

<!--#include virtual="includes/navbar.inc"-->

will look for a file named navbar.inc inside a folder named includes at the same level as the current file. It's a relative path.

If your page is served by a virtual host, the root (/) is at the top level of that host.

File Paths

With the file tag, you use Mac OS pathnames, where folder names are separated by colons (" : ").

The file path can have either standard Macintosh characters, or URL-style encoding ( %20 for space, for example).

File paths can only be absolute (they must start with the hard drive name). For example, this path:

 

<!--#include file="Mac HD:WebSTAR:includes:navbar.inc"-->

would include a file using the full path from the hard drive. You must include the entire path name when using file paths.

When you use file paths, you can serve data that is outside your WebSTAR folder hierarchy. Be careful when you do this, both for security and because it's harder to track and control files in other folders.

Aliases

WebSTAR SSI will resolve the alias, and attempt to load the data in the original file to which the alias points. It will treat the file as though it was in the alias location. However, if the original file cannot be found (perhaps because it's on an unmounted volume), your server will not respond until someone goes to the server machine and mounts that volume.

Error Handling

If for some reason WebSTAR SSI encounters an error while processing your SSI commands, it will replace the SSI command with an appropriate error message inside an HTML comment. If your commands are not working as expected, use "View Source" in your browser to see these error messages. If you see the original SSI command, your Suffix Mapping is probably set incorrectly; if you see an error message, there is likely a syntax error in the SSI command you were trying to use.

You can also replace these default error messages with your own using the #config command, described in Errmsg Tag .

SSI Command Example

This example shows how to display today's date in the default format:

 

Today's date is <!--#echo var="date_local"-->

which looks like this in the browser:

 

Today's date is 1997/10/27:11:52:15 
See also: SSI Command List ; for more information on environmental variables, see SSI Environmental Variables ; to reformat dates, see TimeFmt Tag .

To make the date easier to read, you can add a time format configuration command on the previous line

 

<!--#config timefmt="%B %d, %Y"-->
 
Today's date is <!--#echo var="date_local"-->

will change the date format, then display the current date in the new format:

 

Today's date is October 27, 1997


Manual Contents | Chapter Contents | Previous Page | Next Page