Designers - Conditional if / else Tags

You may add conditional logic to the templates through the use of <s:if condition> / <s:else> tags, for example:


<s:if ~is_auth~ == 0>
    You are not logged in.
<s:else>
    Hello ~profile.username~
</s:if>

The above will check whether or not the global ~is_auth~ variable is equal to 0, and if so display a message saying the user is not logged in, otherwise will display a greeting. A few notes regarding the <s:if> tag:

  • You may use any variables desired within the condition, and they will be replaced with their corresponding value before the condition is evaluated.
  • To use the greater than sign within the condition, use gt, and it will be evaluated as the greater than sign.
  • There is no need to include <s:else> within the block, and its use is optional.