.. include:: /Includes.rst.txt
.. _typo3fluid-fluid-if:
==
if
==
This view helper implements an if/else condition.
**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
- string
::
Will be shown if rank is > 100
Will be shown if rank % 2 != 0.
Checks if rank is equal to the result of the ViewHelper "k:bar"
Will result in true if {foo.bar}'s represented value equals 'stringToCompare'.
= Examples =
This is being shown in case the condition matches
This is being shown in case the condition matches.
This is being displayed in case the condition evaluates to FALSE.
{f:if(condition: someCondition, then: 'condition is met', else: 'condition is not met')}
Arguments
=========
.. _if_then:
then
----
:aspect:`DataType`
mixed
:aspect:`Required`
false
:aspect:`Description`
Value to be returned if the condition if met.
.. _if_else:
else
----
:aspect:`DataType`
mixed
:aspect:`Required`
false
:aspect:`Description`
Value to be returned if the condition if not met.
.. _if_condition:
condition
---------
:aspect:`DataType`
boolean
:aspect:`Required`
false
:aspect:`Description`
Condition expression conforming to Fluid boolean rules