OPT supports conditional instruction if ... elseif ... else ... /if known from programming languages. It allows to show the parts of the template, where specified condition is true. A condidion is a correct OPT expression that should return true or false.
Example 2.48. Conditional instruction
{if $access eq 1}
{* this will be displayed, if $access is equal 1 *}
<p>Welcome, administrator</p>
{elseif $access eq 2}
{* this will be displayed, if the previous condition is false *}
{* and $access is equal 2 *}
<p>Welcome, editor</p>
{else}
{* This will be displayed, if all the conditions are false *}
<p>Permission denied</p>
{/if}Notes:
Example 2.49. Conditions in XML syntax mode
{* Position syntax *}
{if=$access eq 1}
<p>Welcome, administrator</p>
{* XML style syntax *}
{elseif test="$access eq 2"}
<p>Welcome, editor</p>
{/if}