We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46073
    • 65 Posts
    Hi all. I am trying to use output filters with 2 TV elements, here is the filter I'd like to see working:

    [[*myTVOne:is=``:and:myTVTwo:is=``:then=`Nothing Here!`:Else=`Something Here!`]]

    Basically, if both TVs are empty show one thing, but if either has content show another thing. Is that possible?


    ---

    And again, I tried searching the broken search on this forum first but even "Output Filter" returned zero results... thanks for your help.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      No, the output modifiers only work on a single input. You'll need a snippet to handle that situation.
        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
        • 46073
        • 65 Posts
        Bummer and thank you.

        Snippet writing is not my cup of tea.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          This should work (untested)
          $tvOne = $modx->resource->getTVValue('myTVOne');
          $tvTwo = $modx->resource->getTVValue('myTVTwo');
          if(($tvOne == '') && ($tvTwo == '')) {
              return "Nothing Here";
          } else {
              return "Something Here";
          }
            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
            • 46073
            • 65 Posts
            Quote from: sottwell at Jun 19, 2014, 10:37 AM
            This should work (untested)
            $tvOne = $modx->resource->getTVValue('myTVOne');
            $tvTwo = $modx->resource->getTVValue('myTVTwo');
            if(($tvOne == '') && ($tvTwo == '')) {
                return "Nothing Here";
            } else {
                return "Something Here";
            }

            Thank You
              • 4172
              • 5,888 Posts
              you could also try to put them into a chunk

              [[*myTVOne]][[*myTVTwo]]


              and check that chunk with

              [[$myTVOne_myTVTwo:is=``:then=`Nothing Here!`:else=`Something Here!`]]


                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 39519 ☆ A M B ☆
                • 79 Posts
                I use the If snippet for this a lot

                [[If?&subject=`[[*myTVOne]][[*myTVTwo]]` &operator=`empty` &then=`NOTHING` &else=`SOMETHING`]]


                More often I use sottwell's solution though.
                  Mat Dave Jones