We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38677
    • 21 Posts
    Hello all,

    We have got a problem with output filters on a placeholder. (The evaluation also does not work with the If Extra.)

    We are using placeholders to refill a search form after the search has been processed by a snippet.

    - The snippet is not cached
    - Placeholder is set like this: $modx->setPlaceholder('placeHolderName', $_GET['dlgplaceHolderName']);
    - In the chunk, when outputting the placeholder, it returns the correct value: [[+placeHolderName]]
    - But when evaluating it through an output filter (or the If Extra), it always seems to evaluate as FALSE

    We have seen this thread: https://forums.modx.com/index.php?topic=59729.0

    [[!+placeHolderName:is=`5`:then=`selected="selected"`:else=``]] does still not evaluate as TRUE even if outputting [[!+placeHolderName]] in the very same chunk is displaying 5.

    Any ideas?

    Adrian

    PS: This has been productive for a while and we are pretty sure this used to work. We upgraded to 2.2.8. last week. Just an afterthought. [ed. note: elgrandeadi last edited this post 13 years, 3 months ago.]
      • 4172
      • 5,888 Posts
      you are missing the outputfilter itself (:is)

      try

      [[+placeHolderName:is=`5`:then=`selected="selected"`:else=``]]


      for better performance you should allways use else together with conditionals


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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 38677
        • 21 Posts
        Thanks Bruno17. Sorry, that was just an error when modifying the code for the forum. Of course the Output Filter contains the modifier :is. I have modified the original post now to avoid confusion.

        We have also tried the whole list of modifiers: isequalto, isequal, equalto, equals, is, eq.

        Thanks for the performance tip.
          • 43981
          • 7 Posts
          Hi

          We are also facing the same problem as @elgrandeadi. [[+isShowMore:is=`1`:then=`show more`:else=`no`]] is our code.

          If we use [[+isShowMore]] it is showing 1. But with output modifier it is showing 'no' which is coming from the else part.

          We are using Modx revolution 2.2.8 traditional.

          Thanks
            • 3749
            • 24,544 Posts
            See if this works (exclamation point at the beginning):

            [[!+isShowMore:is=`1`:then=`show more`:else=`no`]] 


            How is the isShowMore placeholder being set?
              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
              • 43981
              • 7 Posts
              @BobRay I have tried with uncached call you suggested, but the result is same. I have a snippet call in my resource.

              In the snippet i have this piece of code.

              $modx->setPlaceHolder('isShowMore', 1);
                • 3749
                • 24,544 Posts
                What I usually do in that situation is put a 'selected' placeholder in the form Tpl for each option. Then use a snippet that examines the $_POST and replaces the placeholder with either 'selected="selected"' or '' using str_replace (though you could probably also set the placeholder).

                You need a different placeholder for each option, e.g.:

                [[+red.selected]]
                [[+blue.selected]]
                  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
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I'm having a very similar problem... using "isempty" leaves a blank line in the content, and if I add an :else=`` to it then it returns nothing in all cases, but the empty lines are still there.
                  [[+content:notempty=`[[+pagetitle]] - [[+content]]`]]
                    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
                    • 5904
                    • 58 Posts
                    I'm also noticing a similar issue in a contact form chunk with:

                    [[+idSuffix:is=`Modal`:then=`<div class="other">Other ways to <a href="contactus.html" title="More ways to contact us">Contact us <i class="icon more icon-plus-square"></i></a></div>`:else=``]]


                    When this output modifier is included in the chunk, and idSuffix is null, the rendered page breaks and content is:

                    <div class="other">Other ways to <a href="contactus.html" title="More ways to contact us">Contact us <i class="icon more icon-plus-sign-alt"></i></a></div>
                    `]]
                    </div>


                    followed by bits of html from another page.

                    This used to work well with a previous version of Revo (v2.2.7? Upgraded a few times and first noticed the issue in v2.2.12. Now using v2.3.1).

                    Worked around this by installing the IF extra and using:

                    [[!If? &subject=`[[+idSuffix]]` &operator=`EQ` &operand=`Modal` &then=`<div class="other">Other ways to <a href="contactus.html" title="More ways to contact us">Contact us <i class="icon more icon-plus-square"></i></a></div>`]]


                    but preference would be to not install IF as output modifiers are working well on other parts of the site.

                    Anyone found a solution using output modifiers?
                      • 4172
                      • 5,888 Posts
                      do you perhaps have it nested inside another output-filter?
                      if you have that code inside another chunk, perhaps this chunk is called by another output-filter?

                      search from outside to inside, beginning from your template for outputfilter-nests.
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!