We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33657
    • 128 Posts
       [[*homepage_image:isnot=``:then=`<div>2 columns</div>`:else=`<div>1 Column</div>`]]
    

    is there a better way to do a conditional output for something being empty?

    basically i have a space for an image, and if they don't select an image I want the page to be full width. if they do select a image i want it to be 2 columns... the above works but I am wondering if there is another or better way to do it?

    can you assign conditional output filters to
     'default'
    or
     'isempty'
    etc etc
      • 3749
      • 24,544 Posts
      This would be a little faster:

      [[ImageDiv]]



      <?php
      /* ImageDiv snippet */
      
      return empty($modx->resource->getTVValue('homepage_image'))
         ? '<div>2 columns</div>`
         : `<div>1 Column</div>`;


      I think it would be a little faster yet if you replaced 'homepage_image' with the ID of the TV.

      default and isempty won't really help you because in your case they do the same thing as isnot.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting