I’d like to use “or”, and maybe, “and”, statements within an “if” tag. i.e. if two fields are filled out, or if one or the other field was filled out, something would show. “Else” wouldn’t quite solve this.
Is this possible?
I’d like to use “or”, and maybe, “and”, statements within an “if” tag. i.e. if two fields are filled out, or if one or the other field was filled out, something would show. “Else” wouldn’t quite solve this.
Is this possible?
Hello - Unfortunately, the If
tag does not support or
/ and
statements. It’s mainly due to a limitation with the HTML syntax, that the same tag attribute names (for example, field
and value
) can be used only once.
To help with such combined conditions, there’s a feature called logic variables: https://loop.tangible.one/tags/if/logic
It works by setting a variable like:
<Set logic=complex_condition all=true>
<If first_condition>true<Else />false</If>
<If second_condition>true<Else />false</If>
</Set>
It accepts all=true
or any=true
, for how it combines the conditions.
The If
tag with logic
attribute can use the result.
<If logic=complex_condition>
..
</If>
It’s a little awkward to have to define the conditions separately, but hopefully it’s flexible enough to handle most use cases.