User Tools

Site Tools


en:public:developer:template_system:tags:expression:if

Table of Contents

<#If>

When the interpreter finds an If, it expects a boolean condition – for example ”<#x> > 0”, which means “the variable x contains a number that is greater than zero” – and evaluates that condition. If the condition is true, the content of the param “true” is returned, otherwise the content of the param “false” is returned.

Parameters

Name Mandatory Description
Condition Yes A boolean condition or a number (0 evaluate to false and all other numbers to true). Operators supported: + - * / ( ) OR AND. The tags in the condition are always evaluated before the condition is calculated.
True No The content (html text or template filename) to return if the condition evaluate to true
False No The content (html text or template filename) to return if the condition evaluate to false

Literal

<#if condition=“condition”>true result<#endif>
If the expression specified in condition is true, the contents of the <#if> tags will be output, otherwise nothing will be output.

<#if condition=“condition”>true result<#elseif condition=“condition”>true result<#endif>
Used in conjunction with <#if>, this allows a secondary condition to be checked and the true result to be output if the condition is met.

<#if condition=“condition”>true result<#else>false result<#endif>
Used in conjunction with <#if>, the false result will be output if the <#if> condition failed, and so did any <#elseif> checks.

Example

<#if condition="('<#page_title>' = '') and (<#url_PageNumber> > 1)" 
     true="the page title is empty and the page number is greater than 1"
     false="the page title is NOT empty or the page number is NOT greater than 1">

<#if condition="('#page_title' = '') and (#url_PageNumber = 1)">
  the page title is empty and the page number is equal to 1
<#else>
  the page title is NOT empty or the page number is NOT greater than 1
<#endif>
en/public/developer/template_system/tags/expression/if.txt · Last modified: 2012/11/22 13:09 by admin