MODX Cloud

The Most Productive MODX Learning Playground Ever

Claim Free Lab Account

If

compared with
Current by Maurice Uijlenbroek
on May 19, 2013 14:21.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (5)

View Page History



h3. Development and Bug Reporting




Bugs can be filed here: [http://github.com/splittingred/If/issues]



h2. Usage

The If snippet can be called using the tags:

{code}
[[If]]
{code}
or, in case your subject can be modified before the resource cache get cleared use the uncached syntax:


{code}[[!If]]{code}

]]
{code}
When using the If snippet for checking a resource field or template variable (or other value that doesn't change before the cache does), be sure to use the *cached* snippet call to check the condition to make sure it doesn't need to process on every request.

{code}
[[If?
&subject=`[[*hidemenu]]`
&operator=`EQ`
&operand=`1`
&then=`This resource is not visible in the menu.`
&else=`This resource shows up in the menu in spot [[*menuindex]].`
]]
{code}
As requested an example with inarray.

{code}
[[If?
&subject=`[[*id]]`
&operator=`inarray`
&operand=`3,4`
&then=`This text will show if id is 3 or 4.`
&else=`This text is printed for all other resource id's.`
]]
{code}
\\
{scrollbar}