4.7 IF...ELSEIF...ELSE...ENDIF IFDEF...ELSEIFDEF

Allows conditional inclusion of text into the document. The IF keyword requires a conditional expression. If the conditional expression evaluates to true, the section in the template that follows the IF keyword will be processed until an ELSE, ELSEIF, or an ENDIF is encountered.

If the conditional expression evaluates to false, processing in the template will skip to the next ELSE, ELSEIF, or ENDIF.

Conditional expressions can be combined with && and || for AND and OR expressions respectively.

IFDEF and ELSEIFDEF can be used in place of IF and ELSEIF. IFDEF and ELSEIFDEF require the name of a variable. If the variable exists, the condition evaluates to true.

You can also test the existence of a variable with DEF and NOTDEF. For example,

{IF a == b || (DEF c && NOTDEF d)}
{ENDIF}

Either a equals b, OR c is defined AND d is not defined

There must be a matching ENDIF keyword for every IF keyword.

{IFDEF Folder.count && Folder.count > 0}
{IF Folder.type == Folder.UNIVERSAL}
<IMG src="universal.gif">
{ELSEIF Folder.type == Folder.SHARED}
<IMG src="shared.gif">
{ELSE}
<IMG src="folder.gif">
{ENDIF}
{ELSE}
There are no folders.
{ENDIF}