We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    To be fair, it's not the parser, it's PHP. The empty and default output modifiers call the Php empty() function, which considers empty strings, empty arrays, the number 0 and the string '0' to be empty.

    If you care about page-load times (and you should, since small differences in them have a huge effect on bounce rates), you should really be using a simple snippet for that kind of stuff anyway rather than a conditional output modifier, which is quite slow by comparison.

      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
      • 791
      • 46 Posts
      I'm using MODx Revo 2.3.1

      The problem I have is that the notEmpty operator isn't parsing any markup within it, so in my example

      [[!+sqmHouse:notEmpty:`<span><i class="fa fa-home"></i> [[!+sqmHouse]] m<sup>2</sup></span>`]]


      It's not processing the <span>, <i>, etc. just returning the raw placeholder output, which in my case is a plain number.

      The way round this is to use the If snippet instead. My code now looks like

      [[!if?
      	  &subject=`[[!+sqmHouse]]`
      	  &operator=`!=`
      	  &then=`<span><i class="fa fa-home"></i> [[!+sqmHouse]] m<sup>2</sup></span>`
      	  &else=``
      ]]
      


      Hope this helps someone coming across this thread for the same reason I did.
        Learning a little more each day.
      • That should be
        [[!+sqmHouse:notEmpty=`<span>...`
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 40735
          • 119 Posts
          I have a similar issue.

          <div class="tickets" id="closedTickets" style="[[!+deskx.closedtickets:isnot=``:then=`position:fixed;`:else=`display:none;`]]">


          This outputs "display:none;" regardless of whether or not deskx.closedtickets is empty or not. I've tried it using is, isnot, empty, notempty, and some other variations and they all do the same thing. In my experience the various "empty" modifiers have a long history of not working reliably but until now I've always been able to work around that with is=``:then=``:else=`` but not today. What gives?
            • 3749
            • 24,544 Posts
            You might try removing the exclamation point. Calling it uncached delays the processing of the tag, possibly to a point where the placeholder is empty.
              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
              • 40735
              • 119 Posts
              Quote from: BobRay at Nov 20, 2015, 06:51 AM
              You might try removing the exclamation point. Calling it uncached delays the processing of the tag, possibly to a point where the placeholder is empty.
              That's actually how I had been doing it before I found this thread. Without success unfortunately.

              Is it possible that the placeholder has a newline character or something in it and so it's not technically empty?
                • 3749
                • 24,544 Posts
                What do these (in the TPL chunk) get you?

                <p>DeskX setting --[[!+deskx.closedtickets]]--</p>
                <p>DeskX setting cached --[[+deskx.closedtickets]]--</p>
                  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
                  • 40735
                  • 119 Posts
                  Quote from: BobRay at Nov 20, 2015, 11:37 PM
                  What do these (in the TPL chunk) get you?

                  <p>DeskX setting --[[!+deskx.closedtickets]]--</p>
                  <p>DeskX setting cached --[[+deskx.closedtickets]]--</p>

                  So here's the surrounding code:
                  <div class="tickets" id="closedTickets" style="[[+deskx.closedtickets:default=`display:none;`]]">
                              <ul class="nav nav-pills nav-stacked">
                                  [[!+deskx.closedtickets]]
                                  <!--------------------->
                                  [[+deskx.closedtickets]]
                              </ul>
                          </div>


                  And here's the source in the client:
                  <div class="tickets" id="closedTickets" style="display:none;">
                              <ul class="nav nav-pills nav-stacked">
                                  <li><a href='help?tid=7'>I have issues. I need you to fix them.<br><small>tntech.edu</small></a><li><a href='help?tid=6'>New Issue! Please Halp!<br><small>/help</small></a><li><a href='help?tid=4'>Does this work?<br><small>www.tntech.edu/help</small></a>
                                  <!--------------------->
                                  <li><a href='help?tid=7'>I have issues. I need you to fix them.<br><small>tntech.edu</small></a><li><a href='help?tid=6'>New Issue! Please Halp!<br><small>/help</small></a><li><a href='help?tid=4'>Does this work?<br><small>www.tntech.edu/help</small></a>
                              </ul>
                          </div>
                  
                  
                    • 3749
                    • 24,544 Posts
                    That's crazy. It must be an issue with the parsing order. My guess is that the conditional is being parsed at a point where the placeholder is empty, even though it's obviously set at the end.

                    I would try something like this, with a custom snippet:

                    <div class="tickets" id="closedTickets" style="[[!GetStyle? &value=`[[+deskx.closedtickets]]` ]]">


                    <?php
                    /* GetStyle snippet */
                    return empty($scriptProperties['value'])? 'display:none;' : 'position:fixed;';
                    
                      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
                      • 40735
                      • 119 Posts
                      That was it! When you mentioned the parse order I realized I was calling [[!deskx]] after all my placeholders. This doesn't seem to matter for delivering content to the them but it apparently does matter for the output filters. I flipped them in the source order and it's working as expected now. And I got the behavior I wanted from the output filters with this:
                      [[+deskx.closedtickets:is=``:then=`display:none;`:else=``]]


                      Thanks!