SSI directives look rather like HTML comment tags. The syntax is as follows:
<!--#element attribute=value attribute=value ... -->
The element can be one of several directives, including
The following sections describe each of these directives and their uses. config
The config directive enables you to set various configuration options to determine how the document parsing is handled. Because the page is parsed from top to bottom, config directives should appear at the top of the HTML document. Three configurations can be set with this command:
• errmsg Sets the error message that's returned to the client if something goes wrong while parsing the document. The default message is [an error occurred whiie processing this directive], but you can set the message to any text with this directive. For example,
<!—#config errmsg="[It's broken, dude]" —>
• sizefmt Sets the format used to display file sizes. You can set the value to bytes to display the exact file size in bytes or set it to abbrev to display the size in KB or MB. For example,
• timefmtU Sets the format used to display times. The format of the value is the same as that of the strftime function used by C (and Perl) to display dates, as shown in the following list:
o %a Day of the week abbreviation o %a Day of the week o %b Month abbreviation o %b Month
O %c ctime format: Sat Nov 19 21:05:57 1994
o %d Numeric day of the month o %e DD
o %h Month abbreviation o %h Hour, 24-hour clock, leading zeroes o %i Hour, 12-hour clock, leading zeroes o %j Day of the year o %k Hour o %l Hour, 12-hour clock o %m Month number, starting with 1 o %m Minute, leading zeroes o %n NEWLINE
o %o Ordinal day of month1st, 2nd, 25th, and so on o %p AM or PM
o %r Time format: 09:05:57 pm o %rTime format: 21:05 o %s Seconds, leading zeroes o %t Tab o %t Time format: 21:05:57 o %u Week number; Sunday as first day of week o %w Day of the week, numerically; Sunday = 0 o %w Week number; Monday as first day of week o %x Date format: 11/19/94 o %x Time format: 21:05:57 o %y Year (two digits) o %y Year (four digits) o %z Time zone in ASCII, such as PST
The echo directive displays any one of the include variables in the following list. Times are displayed in the time format specified by timefmt. Use the var attribute to indicate the variable to be displayed:
• date_gmt The current date in Greenwich mean time.
• date_local The current date in the local time zone.
• document_name The filename (excluding directories) of the document requested by the user.
• document_uri The (%-decoded) URL path of the document requested by the user. Note that in the case of nested include files, this isn't the URL for the current document.
• last_modified The last modification date of the document requested by the user.
The exec directive executes a shell command or a CGI program, depending on the parameters you provide. Valid attributes are cgi and cmd:
• cgi The URL of a CGI program to be executed. The URL must be a local CGI, not one located on another machine. The CGI program is passed the query_string and path_info that were originally passed to the requested document, so the URL specified cannot contain this information. You should use include virtual instead of this directive.
• cmd A shell command to be executed. The results are displayed on the HTML page.
The fsize directive displays the size of a file specified by either the file or virtual attribute. Size is displayed as specified with the sizefmt directive:
• file The path (file system path) to a file, either relative to the root if the value starts with / or relative to the current directory if it doesn't
• virtual The relative URL path to a file flastmod
Displays the last modified date of a file. The desired file is specified as with the fsize directive.
The include directive includes the contents of a file. The file is specified with the file and virtual attributes, as with fsize and flastmod.
If the file specified is a CGI program and includesNoEXEc isn't set, the program is executed and the results are displayed. This is to be used in preference to the exec directive. You can pass a query_string with this directivesomething you can't do with the exec directive.
It displays all existing variables and has no attributes. For example,
This sets the value of a variable, and its attributes are var and value. For example,
<!--#set var="animal" value="cow" —>
Was this article helpful?