Conditionals for modx template variables
/* if the content of the variable is empty do nothing
otherwise display the content (for single TV use only) */
[[*templateVariable:notempty=`` ]]
/* example */
[[*templateVariable:notempty=`<img src="stuff.jpg">` ]]
/* for full layouts, make sure "else" part is on its own line. */
[[*templateVariable:!empty=`
<section>
<div>Do Something</div>
</section>
`:else=``]]
/* Hide Section if no child resources */
[[$chunk:notempty=`<section>[[$chunk]]</section>`]]
/* for the date variable - set its default to 0 */
[[*startDate:is=`0`:then=`
<p>
Do this if a date HASN'T been set
</p>
`:else=`
<p>
Do this if a date HAS been set
</p>
`]]
/* conditional layouts if template variable is empty */
[[!*templatevariable:is=``:then=`Do this `:else=`do that`]]
/* IF id of Page is '' then do something or do something else */
[[*id:eq=`15`:then=`<p>Do something or nothing</p>`:else=`<p>Do something Else</p>`]]
/*MODX-EVO template variables eg: [*stuff*]. If stuff is empty then do nothing otherwise do 'then' */
[*stuff:isnot=``:then=`<div class="slide" style="background-image:url([*stuff*])"> </div>`:else=``*]
Reference
Get In Touch
Have a question? or perhaps spotted a problem?
Maybe you have something you would like to add. Drop us a line anytime!


