We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26016
    • 561 Posts
    Hi,
    I’m learning more and more about Revo each day. Today, I’m thinking, I wonder what it does for PHx stuff? And Boom, I find Output Filters for TV’s! Just awesome.

    The very first one, "cat" (for concatenate, I assume) is EXACTLY what I like to use PHx for... display some extra text along with the variable, like a label or whatever, if the TV is populated, otherwise, display nothing.

    When I test, though, it does concatenate its little brains out! But when I empty the TV, it still displays the extra test, unlike the way it’s advertised in the documentation. So a little less excitement. smiley I had been using an Image TV, I tried it as Text, to see if it would work that way.

    I guess I could play around with longer syntax and try the noempty type stuff maybe. Any insights appreciated.

    Cheers, Dave

    PS: Other parts of the documentation include what appear to be calls with the plus-sign instead of asterisk... I surmised that this might be cacheing or something, but could find nothing that explained the difference. The call did appear to work both ways.

      MODx and Wordpress development
      Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
      • 3749
      • 24,544 Posts
      It’s behaving as it should. It’s concatenating the extra stuff on the end of the existing string (empty or not). I think you’d need to use ifEmpty to do what you want (although a simple snippet would probably be faster):

      [[!MyCat? &tvName=`myTv` &extra=`The extra stuff`]]


      <?php
      /* MyCat snippet */
      
      $tv = $modx->getChunk($tvName);
      
      $retVal = '';
      
      If ($tv) {
      $retVal = $tv . $extra;
      }
      return $retVal
        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
        • 4971
        • 964 Posts
        The asterisk is used when you call a TV in a normal way...
        the plus sign is used inside a snippet or extra...
          Website: www.mercologia.com
          MODX Revo Tutorials:  www.modxperience.com

          MODX Professional Partner
          • 26016
          • 561 Posts
          Guys,
          Thanks for those excellent replies. Bob, you’re a true ace, without you around, Revo would have been a lot more difficult to me (and others) to learn.

          I had wondered if that was default behavior... that little typo in the documentation just got me all excited. Man, am I a cheap date! smiley
          http://rtfm.modx.com/display/revolution20/Input+and+Output+Filters

          But as long as I can do it another way, it’s all good. Just not needing PHx is so great.

          Oh, and I forgot to mention yesterday... those context-based lightbox-y Help pop-ups in Revo are an extremely pleasant surprise!! Wow. Talk about a time-saver, and this could really help sell the system to a newbie.

          Thanks again, Dave
            MODx and Wordpress development
            Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
            • 25663 MODX Staff
            • 12,272 Posts
            For what it’s worth, filters can be applied to anything in Revo, including chunks, document objects, etc.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me