We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5340
    • 1,624 Posts
    Hi,

    I am currently playing with some Revo stuff and I discovered the following:

    Using this:
    [[!++systemSetting:if=`[[++systemSetting]]`:is=``:then=`EMPTY`:else=`-[[++systemSetting]]-`]]


    systemSetting is not a valid system setting so the output should be "EMPTY". Instead I get "--"


    [[!++systemSetting:empty=`EMPTY`]]


    This seems to work as the output is "EMPTY"

    Thanks


      • 3749
      • 24,544 Posts
      MODx tags are meant to work with objects that exist, so the results of using a tag with modifiers to display an object that doesn’t exist would probably be unwise even if it worked. Also, boolean (yes/no) system settings might contain a ’0’ which would be interpreted as empty even though they exist and other system settings could contain empty strings.

      A simple snippet would be much more efficient anyway and could tell you if a setting doesn’t exist. Something like this:
      [[!GetSetting? &systemSetting=`filemanager_path`]]

      <?php 
      /* GetSetting snippet */
      $output = $modx->getOption($systemSetting);
      if ($output === null ) {
         $output = 'Setting Does not exist';
      } elseif (empty($s)) {
         $output = 'Setting is empty';
      }
      
      return $output;
      ?>
        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
        • 5340
        • 1,624 Posts
        Hi Bob,

        I wanted to play with the output filters and the easiest way was to use system settings instead of placeholders or TVs.
        If I’m correct the above should happen for TVs and placeholders as well. I have to do some more testing but the results should be the same.

          • 3749
          • 24,544 Posts
          Hi Cipa,

          It should be the same, but if you’re just playing around, you might as well stick to stuff that actually exists (but might be empty), since it’s unlikely that you’d ever want to use an existing output modifier on a non-existent object. wink

          If you really need a test of whether the thing exists, you’d probably want a custom output modifier.

            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