This component will display its contents if the comparison is true. The default comparison will test if the value is "truthy" based on PHP's truth table. If the comparison evaluates to false this component will only display the contents that are within the fm:else node.
In this example "failure" will be displayed if the value is 0, an empty string, or a string of only whitespace characters. Anything else will yield "success".
<fm:If value="{$$get.msg}">
success
<fm:Else>
failure
</fm:Else>
</fm:If>
This will test the value to see if it's an integer. This may be important when checking if you're working with a number that could be a valid page number or a media item's offset in a list.
<fm:If value="{$$get.offset}" comparison="integer">
Displaying entry {$$get.offset}
<fm:Else>
Sadly we're currently unable to support fractional media items :(
</fm:Else>
</fm:If>
This will test to see if the value matches the provided regex
<fm:If value="{$$get.query}" comparison="matches" compareTo="/.*Blue.*/">
We found Blue
<fm:Else>
Sorry, this does not contain the word Blue
</fm:Else>
</fm:If>
To test if one value is greater than another you may specify "gt" (greater-than) or "lt" (less-than) as the comparison:
<fm:If value="{$$get.rating}" comparison="gt" compareTo="3">
This got a rating greater than 3!
<fm:Else>
This got a rating of 3 or lower.
</fm:Else>
</fm:If>
To test if one value is greater-than / less-than, or equal-to, another you may specify "gte" (greater-than-or-equal-to) or "lte" (less-than-or-equal-to) as the comparison:
<fm:If value="{$$get.rating}" comparison="gte" compareTo="3">
This got a rating greater than or equal to 3!
<fm:Else>
This got a rating less than 3.
</fm:Else>
</fm:If>
Name | Required | Default | Description |
---|---|---|---|
compareTo | Optional | N/A | The variable to compare to, if applicable |
comparison | Optional | truthy | The operation to use to test, one of: "truthy", "=", "gt", "gte", "lt", "lte", "integer","contains","inList","empty\,"notempty","matches" |
delimiter | Optional | N/A | Required it comparison is of time inList, eg. ca,us,fr,sp. Delimiter would be ',' |
value | Required | N/A | The variable to test |