ibexa

Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.

if

Summary

Allows conditional control by the way of an IF-THEN-ELSE mechanism.

Usage

{if <condition>}
...
[ {elseif <condition>} ]
...
[ {else} ]
...
{/if}

Description

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.

Examples

Example 1

{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.

Example 2

{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.".

Example 3

{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".

Balazs Halasy (22/02/2005 1:09 pm)

Balazs Halasy (28/04/2005 8:29 am)


Comments

There are no comments.