fm:If
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.
Simple example using the default comparison ("truthy")
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>
Testing for an integer
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>
Comparing two numbers
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>
Supported Attributes
| 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", "lt", "integer" |
| value | Required | N/A | The variable to test |
developer documentation r21357