|
Web Design > SSI Flow Control The basic flow control elements are: <!--#if expr="test_condition" --> <!--#elif expr="test_condition" --> <!--#else--> <!--#endif--> The if element works like an if statement in a programming language. The test condition is evaluated and if the result is true, then the text until the next elif, else. or endif element is included in the output stream The elif or else statements are be used to put text into the output stream if the original test_condition was false. These elements are optional. The endif element ends the if element and is required. test_condition Is One of the Following:
<!--#if expr="$a = test1 && $b = test2" --> <!--#if expr="($a = test1) && ($b = test2)" --> Anything that's not recognized as a variable or an operator is treated as a string. Strings can also be quoted: 'string'. Unquoted strings can't contain whitespace (blanks and tabs) because it is used to separate tokens such as variables. If multiple strings are found in a row, they are concatenated using blanks. So, string1 string2 results in string1 string2 'string1 string2' results in string1 string2 Variable substitution is done within quoted strings. You can put a dollar sign into the string using backslash quoting: <!--#if
expr="$a = \$test" --> Example The below example will print "in foo" if the DOCUMENT_URI is /foo/file.html, "in bar" if it is /bar/file.html and "in neither" otherwise: <!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\"" --> in foo <!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\"" --> in bar <!--#else--> in neither <!--#endif-->
|
