We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49359
    • 16 Posts
    Please help !. I have 3 TVs.
    And I need to display the button only if all of the TV is not empty.
    I understand that this code is not correct. But how to solve this by using filters

    [[*services-in-room:notempty=``:and:*services-in-bathroom:notempty=``:and:*the-price-includes:notempty=``:then=`<a class="rooms-services">conteng</a>`]]



    This question has been answered by multiple community members. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Output modifiers aren't able to handle that kind of multiple conditional. You'll need a custom snippet.
        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
        • 13428 ☆ A M B ☆
        • 1,031 Posts
        It is possible as far as I know (in Evo this worked):
        [[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]:isnot=``:then=`<a class="rooms-services">conteng</a>`]]


        notempty is not a conditional modifier and you have to call the other TVs with if=`[[*tvname]]`
          • 49359
          • 16 Posts

          Quote from: sottwell at Nov 26, 2014, 07:35 AM
          Output modifiers aren't able to handle that kind of multiple conditional. You'll need a custom snippet.
          How I can write this snippet?)
            • 49359
            • 16 Posts
            Quote from: Jako at Nov 26, 2014, 09:08 AM
            It is possible as far as I know (in Evo this worked):
            [[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]:isnot=``:then=`<a class="rooms-services">conteng</a>`]]


            notempty is not a conditional modifier and you have to call the other TVs with if=`[[*tvname]]`

            Sorry, but this moddificators dont works((
            • discuss.answer
              • 3749
              • 24,544 Posts
              A custom snippet will be much faster (untested):


              [[!CheckServices]]



              /* CheckServices snippet */
              $tvNames = array(
                  'services-in-room',
                  'services-in-bathroom',
                  'the-price-includes'
              );
              
              foreach($tvNames as $name) {
                  if (empty($modx->resource->getTVValue($name))) {
                      return '';
                  }
              }
              
              return '<a class="rooms-services">conteng</a>';
              







                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
              • discuss.answer
                • 13428 ☆ A M B ☆
                • 1,031 Posts
                @Bob: Much faster is (almost) ignorable since it is used direct in the template and not in an iterated getResources chunk. And it is cacheable as far as I know.

                @Nort: There was an missing ` in the modifier chain:
                [[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]`:isnot=``:then=`<a class="rooms-services">conteng</a>`]]

                Thats the true reason to avoid such long output filter chains. Nested conditionals could cause problems too and should be avoided.
                  • 49359
                  • 16 Posts
                  Quote from: Jako at Nov 26, 2014, 01:45 PM
                  @Bob: Much faster is (almost) ignorable since it is used direct in the template and not in an iterated getResources chunk. And it is cacheable as far as I know.

                  @Nort: There was an missing ` in the modifier chain:
                  [[*services-in-room:isnot=``:and:if=`[[*services-in-bathroom]]`:isnot=``:and:if=`[[*the-price-includes]]`:isnot=``:then=`<a class="rooms-services">conteng</a>`]]

                  Thats the true reason to avoid such long output filter chains. Nested conditionals could cause problems too and should be avoided.
                  Thank you!
                    • 49359
                    • 16 Posts
                    Quote from: BobRay at Nov 26, 2014, 12:23 PM
                    A custom snippet will be much faster (untested):


                    [[!CheckServices]]



                    /* CheckServices snippet */
                    $tvNames = array(
                        'services-in-room',
                        'services-in-bathroom',
                        'the-price-includes'
                    );
                    
                    foreach($tvNames as $name) {
                        if (empty($modx->resource->getTVValue($name))) {
                            return '';
                        }
                    }
                    
                    return '<a class="rooms-services">conteng</a>';
                    







                    Thank you,Bob!