{if <condition>} ... [ {elseif <condition>} ] ... [ {else} ] ... {/if}
This construct allows for conditional execution of code fragments. It is one of the most important features of many programming languages. The eZ Publish implementation makes it possible to do conditional branching by the way of the following elements: IF, ELSE and ELSEIF. The ELSE and ELSEIF elements are optional.
{if eq( $var, 128 )} Hello world <br /> {/if}
If $var equals 128, the following output will be produced: "Hello world". If it does not equal 128, no output will be produced.
{if eq( $var, 128 )} Hello world <br /> {else} No world here, move along. <br /> {/if}
If $var equals 128, the following output will be produced: "Hello world". If it does not equal 128, the output will be "No world here, move along.".
{if eq( $fruit, 'apples' )} Apple tree <br /> {elseif eq( $fruit, 'oranges' )} Orange juice <br /> {else} Banana split <br /> {/if}
If $fruit equals "apples", the output will be "Apple tree", if it equals "oranges" then the output will be "Orange juice" - otherwise the output will be "Banana split".
Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.