![]() | |
| |
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 |
Advanced FeaturesPrintenvThe printenv command displays all of the system variables and their values.<--#printenv --> SetThis allows you to set the value of a variable, and is useful in confunction with the if/then/else directives.<--#set var="varname" value="data" --> If / Then / ElseThese allow you to select different things to display, base on the contents of the various variables. For example, you might want to do something different for users whose HTTP_USER_AGENT contains "MSIE" (i.e. Internet Explorer Users) than for those who use Netscape. Or maybe you could use this in a template file for a collapsable menu, and expand the appropriate section by using theset command within the parent file...
<!--#if expr="condition" --> (this is displayed if first condition is met) <!--#elif expr="condition" --> (otherwise this is displayed if second condition is met) <!--#else --> (if neither condition is met, this is displayed) <!--#endif -->The condition is a comparison between two strings, using the operators =, != (not equals), <, <=, >, and >= Compound conditions can be made by using ((Condition1) && (Condition2)) (AND), ((Condition1) || (Condition2)) (OR), (!(Condition1)) (NOT), and any combination of these.
The parentheses are not always required, but do no harm and improve readability.
For information on how to compare the contents of variables, see the next section. Variable SubstitutionTo use a variable's data as the value to be displayed or compared, or the file to be accessed, simply enter the variable name with a $ sign in front of it.Example : <--#if expr="$varname = 'test'" -->If the variable varname is equal to the string "test", then the if statement will evaluate to true. This technique can be used for almost any of the SSI commands.
Notes:
(C)opyright, Geoff Knagge.
Continued use of this site indicates your agreement to the Conditions of use and Privacy Policy. |