ViewHelper Documentation
if
This view helper implements an if/else condition. Check \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\ViewHelperNode::convertArgumentValue() to see how boolean arguments are evaluated
Conditions:
As a condition is a boolean value, you can just use a boolean argument. Alternatively, you can write a boolean expression there. Boolean expressions have the following form: XX Comparator YY Comparator is one of: ==, !=, <, <=, >, >= and % The % operator converts the result of the % operation to boolean.
XX and YY can be one of:
- number
- Object Accessor
- Array
- a ViewHelper
a String
<f:if condition="{rank} > 100"> Will be shown if rank is > 100 </f:if> <f:if condition="{rank} % 2"> Will be shown if rank % 2 != 0. </f:if> <f:if condition="{rank} == {k:bar()}"> Checks if rank is equal to the result of the ViewHelper "k:bar" </f:if> <f:if condition="{foo.bar} == 'stringToCompare'"> Will result true if {foo.bar}'s represented value equals 'stringToCompare'. </f:if>
= Examples =
<f:if condition="somecondition">
This is being shown in case the condition matches
</f:if>
<f:if condition="somecondition">
<f:then>
This is being shown in case the condition matches.
</f:then> <f:else>
This is being displayed in case the condition evaluates to FALSE.
</f:else> </f:if>
{f:if(condition: someCondition, then: 'condition is met', else: 'condition is not met')}
Arguments
then string, required
Value to be returned if the condition if met.
else string, required
Value to be returned if the condition if not met.
condition string, required