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. */

          <div>Do Something</div>

/*  Hide Section if no child resources  */


/* for the date variable - set its default to 0 */

             Do this if a date HASN'T been set
           Do this if a date HAS been set
/* 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=``*]


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!