We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37042
    • 384 Posts
    Hi guys
    Here's an odd thing regarding Output Filters and getResources.

    I have the following Output Filter working on my META Tags.

    <meta name="description" content=" [[*description:is=``:then=`[[*content:notags:strip:limit=`153`]]`]]" />
    


    In plain English, this is what happens:

    • use the Description field for my pages 'description' meta tag
    • if the description field is empty, use the content field instead
    • strip all html tags from the content
    • limit to to 153 carachters

    Seems to work perfectly on every page apart from a particular page which has a getResources call in the content field.

    [[!getResources? &parents=`51` &tpl=`Listing-Thumb-Text` &includeTVs=`1` &processTVs=`1` &includeContent=`1` &sortdir=`ASC`]]
    


    In this case, it outputs the entire chunk and html twice on the page IE Once in the HEAD and once in the BODY of the page.
    Maybe I'm trying to be too complicated here but would be interested in feedback.

    Thanks.




      ...
      • 13218
      • 134 Posts
      I'm really not sure, but the first thing that comes to mind would be the order in which modx parses cached and uncached tags. As i understand it (and 'understanding' here is often accompanied by a mild headache), cached tags are parsed before uncached tags and nested tags are parsed inside-out.

      So something like this might be happening here:
      your head-tag [[*content]] is cached, hence it is parsed first. It retrieves the content and puts it in the header.
      But the content has an uncached tag [[!getResources]]. This, since uncached, is not parsed, so you actually have to unparsed getResource call in your header. And now this gets parsed, meaning the output of getResource is put inside your header.

      Try calling your header tag uncached: [[!*description:is=``:then=`[[!*content:notags:strip:limit=`153`]]`]]
      If this makes a difference, then i'm on the right track.

      Cheers,
      Marc

      For additional information on caching visit these excellent Mark Hamstra posts:

      https://www.markhamstra.com/modx-blog/2011/10/caching-guidelines-for-modx-revolution/
      https://www.markhamstra.com/modx-blog/2011/11/nested-caching-in-modx-revolution/ [ed. note: itWillBeOk last edited this post 13 years, 9 months ago.]
        @itWilllBeOK
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        Holy Smokes and Leapin' Lime Lizards Batman!

        It actually WILL be OK!!

        I think you're onto something there, but I'm only on one test of it. Need to see it work a few more times and pull the content in to really believe it. The only problem now that I see is that for those resources with chunk or snippet calls in the first 200 characters, there's not so much in the way of output from the meta name tag in the source. Regular text now works fabulously and pages don't break due to the double parsing. WOOT!!! Thank You!

        Been battling this one for far too long now, it isn't only chunks that execute in the head, snippets do as well. Hot diggity dog!

        Now I have to go and fix a whole bunch of head chunks. But that's good! :~}
          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Don't forget that recent discussion on output modifiers with no else: statements. I believe adding an appropriate else: statement solved similar problems. https://forums.modx.com/thread/81146/output-modifier-works-only-with-tvs-set#dis-post-447180
            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
            • 10208 ☆ A M B ☆
            • 1,780 Posts
            Yano... I totally disregarded that thread's discussion when it came to output modifiers in the head. Doh! I think I'm the one who brought it up too. Double Doh! for that Kori.

            PRoblem is... in the case of a snippet or chunk being in the first 200, what "else" am I gonna ask it to do?
              Frogabog- MODX Websites in Portland Oregon
              "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
              Having server issues? These guys have MODX Hosting perfected - SkyToaster
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I would think that the notags directive would prevent re-loading any MODx tags into the modified output.
                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
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                (if somebody doesn't do something about this default checked status for the "Email me new replies" box, I'm going to HURT somebody)
                  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
                  • 10208 ☆ A M B ☆
                  • 1,780 Posts
                  Quote from: sottwell at Jan 07, 2013, 06:18 PM
                  I would think that the notags directive would prevent re-loading any MODx tags into the modified output.

                  It doesn't seem to work.
                    Frogabog- MODX Websites in Portland Oregon
                    "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                    Having server issues? These guys have MODX Hosting perfected - SkyToaster
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Hm. Docs seem to agree; apparently it only strips HTML tags. I thought there used to be one that stripped MODx tags. Maybe it was a custom modifier.
                      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
                      • 10208 ☆ A M B ☆
                      • 1,780 Posts
                      I never looked deep enough in the rtfm to find that. I always thought it was referring to MODX tags. Or, maybe that was just wishful thinking.
                        Frogabog- MODX Websites in Portland Oregon
                        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
                        Having server issues? These guys have MODX Hosting perfected - SkyToaster