User Tools

Site Tools


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

This is an old revision of the document!


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.

Attributes

  • condition - 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 - The content (html text or template filename) to return if the condition evaluate to true
  • false - 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.

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

<#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 greater than 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.1353100488.txt.gz · Last modified: 2012/11/17 01:14 by admin