![]() | |
| |
HomeWeb DevelopmentShort ContentsIntroductionSSI Commands Advanced Full ContentsIntroductionWhat is SSIWhat you need Setting up SSI SSI Commandsconfiginclude echo fsize flastmod exec AdvancedPrint VariablesSet Variables If / Then / Else Variable Substitution |
The Special CommandsAll of the special SSI tags appear in HTML files in the following form:<!--#element attribute1=value1 attribute2=value2 ... -->In the above, element is the command name, which may be followed by one or more attributes that specify what information to display. The attributes are assigned values, often in quotes, and usually only one attribute can be specified per command. See the specific commands for details.
Config - error messages, time and file size formatThe config command is used to customise error messages, and to specify formatting of date and file size information.<!--#config errmsg="value" --> <!--#config timefmt="value" --> <!--#config sizefmt="value" -->The available attributes are all optional, and are:
<!--#config errmsg="[Something went wrong...]"--> <!--#config sizefmt="abbrev"--> Date Representation StringsThe following was taken directly from the Unix manual files for strftime, and contains the special symbols used to specify a custom date format string. For example,<!--#config timefmt="%r on %A, %e %B %G" --> <!--#echo var="DATE_LOCAL" -->produces... 08:01:26 PM on Wednesday, 8 October 2025 %% Same as %. %a Locale's abbreviated weekday name. %A Locale's full weekday name. %b Locale's abbreviated month name. %B Locale's full month name. %c Locale's appropriate date and time representation. %C Locale's date and time representation as produced by date(1). %C Century number (the year divided by 100 and trun- cated to an integer as a decimal number [1,99]); single digits are preceded by 0; see standards(5). %d Day of month [1,31]; single digits are preceded by 0. %D Date as %m/%d/%y. %e Day of month [1,31]; single digits are preceded by a space. %g Week-based year within century [00,99]. %G Week-based year, including the century [0000,9999]. %h Locale's abbreviated month name. %H Hour (24-hour clock) [0,23]; single digits are preceded by 0. %I Hour (12-hour clock) [1,12]; single digits are preceded by 0. %j Day number of year [1,366]; single digits are pre- ceded by 0. %k Hour (24-hour clock) [0,23]; single digits are preceded by a blank. %l Hour (12-hour clock) [1,12]; single digits are preceded by a blank. %m Month number [1,12]; single digits are preceded by 0. %M Minute [00,59]; leading 0 is permitted but not required. %n Insert a NEWLINE. %p Locale's equivalent of either a.m. or p.m. %r Appropriate time representation in 12-hour clock format with %p. %R Time as %H:%M. %S Seconds [00,61]; the range of values is [00,61] rather than [00,59] to allow for the occasional leap second and even more occasional double leap second. %t Insert a TAB. %T Time as %H:%M:%S. %u Weekday as a decimal number [1,7], with 1 representing Sunday. %U Week number of year as a decimal number [00,53], with Sunday as the first day of week 1. %V The ISO 8601 week number as a decimal number [01,53]. In the ISO 8601 week-based system, weeks begin on a Monday and week 1 of the year is the week that includes both January 4th and the first Thursday of the year. If the first Monday of January is the 2nd, 3rd, or 4th, the preceding days are part of the last week of the preceding year. See NOTES below. %w Weekday as a decimal number [0,6], with 0 representing Sunday. %W Week number of year as a decimal number [00,53], with Monday as the first day of week 1. %x Locale's appropriate date representation. %X Locale's appropriate time representation. %y Year within century [00,99]. %Y Year, including the century (for example 1993). %Z Time zone name or abbreviation, or no bytes if no time zone information exists. %Ec Locale's alternate appropriate date and time representation. %EC Name of the base year (period) in the locale's alternate representation. %Eg Offset from %EC of the week-based year in the locale's alternative representation. %EG Full alternative representation of the week-based year. %Ex Locale's alternate date representation. %EX Locale's alternate time representation. %Ey Offset from %EC (year only) in the locale's alter- nate representation. %EY Full alternate year representation. %Od Day of the month using the locale's alternate numeric symbols. %Oe Same as %Od. %Og Week-based year (offset from %C) in the locale's alternate representation and using the locale's alternate numeric symbols. %OH Hour (24-hour clock) using the locale's alternate numeric symbols. %OI Hour (12-hour clock) using the locale's alternate numeric symbols. %Om Month using the locale's alternate numeric sym- bols. %OM Minutes using the locale's alternate numeric sym- bols. %OS Seconds using the locale's alternate numeric sym- bols. %Ou Weekday as a number in the locale's alternate numeric symbols. %OU Week number of the year (Sunday as the first day of the week) using the locale's alternate numeric symbols. %Ow Number of the weekday (Sunday=0) using the locale's alternate numeric symbols. %OW Week number of the year (Monday as the first day of the week) using the locale's alternate numeric symbols. %Oy Year (offset from %C) in the locale's alternate representation and using the locale's alternate numeric symbols. Including Files within a fileThe include command is used to insert a document within a document. For example, you may want to specify the page template for a site and import this in each of your pages, so you only need to change one file if you decide to change your layout.You can include other SHTML files, but not CGI scripts. <!--#include virtual="value" --> <!--#include file="value" -->
<!--#include virtual="/templates/guideheader.t" --> Echo - file names and datesThe Echo command is used to print certain system variables on the web page:<!--#echo var="value" -->Value is one of the following :
Fsize - file sizeThe fsize command displays the file size of the specified file, in a format given by thesizefmt option of the config command.
<!--#fsize virtual="value" --> <!--#fsize file="value" -->
<!--#fsize virtual="/index.html" --> Flastmod - file last modified dateThe flastmod command displays the file size of the specified file, in a format given by thetimefmt option of the config command.
<!--#flastmod virtual="value" --> <!--#flastmod file="value" -->
<!--#flastmod virtual="/index.html" --> Exec - CGI or shell command executionThis allows you to execute CGI or system commands, and display the results on the web page. For security reasons, this is usually disabled in the web server by default, and must be enabled in the config file if you wish to use it.<!--#exec cmd="value" --> <!--#exec cgi="value" -->
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy. |