Conditional logic within Widgets

From GruppoZenit
Jump to: navigation, search

In Z-CMS, it is possible to realize conditional logic within Widgets using the Z-CMS conditional tags zcms:is and zcms:else.


A conditional operation that is performed against two values has to be included in the zcms:is tag. zcms:else tag has to be enclosed within the zcms:is tag for managing the case when particular conditional operation evaluates to false.


An example of the use of conditional tags is given below:

<zcms:is attribute="menu_identifier" operation="EQUALS" value="$request[$3]">
   Condition true
   <zcms:else>
   Condition false
   </zcms:else>
</zcms:is>


Here, content data of the attribute "menu_identifier" is evaluated for equality against a value that is obtained from the page "request".


Z-CMS supports the following conditional operations:

  • EMPTY, NOT_EMPTY
  • EQUALS, NOT_EQUALS
  • CONTENT_POSITION_FIRST, CONTENT_POSITION_NOT_FIRST, CONTENT_POSITION_LAST, CONTENT_POSITION_NOT_LAST
  • CONTENT_POSITION_ODD, CONTENT_POSITION_EVEN, CONTENT_POSITION_MOD


Example: use conditional logic within Widgets

In the following example it is shown how to use conditional logic within a Widget:

<zcms:content name="Academy_Box">
   <zcms:dataorder attribute="priority" order="asc"/>  
      <zcms:is attribute="type" operation="EQUALS" value="1">
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
               <td><p><zcms:attribute name="Description"/></p></td>
            </tr>
            <tr>
               <td><p><img src="[zcms:attribute:image]" height="223" width="223"/></p></td>
	    </tr>
         </table>
      <zcms:else>
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td><p><zcms:attribute name=”Over” /></p></td>
            </tr>
         </table>
      </zcms:else>
   </zcms:is>
</zcms:content>

See also

Personal tools
Namespaces

Variants
Actions
Toolbox