We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    This has come up for me a few times, but I always had a workaround... until now.

    What can be done? I’m developing a Snippet that grabs chunks, replaces some place-holders in those chunks, then spits the formatted results back to the page... but any [!Snippet!] calls on that page do not render. They don’t execute.

    Is this a bug? Is there some magic way to make MODx re-evaluated the contents of the page to find and execute my Snippet calls? Does this have anything to do with the setting in the index.php file:
    $modx->maxParserPasses = 10; // max number of parser recursive loops or passes
    


    Thoughts? Suggestions?

    Many thanks.
      • 20413
      • 2,877 Posts
      Did you try [[...]] smiley
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Wow.... wild... I was gonna say "where’s the love?!" but running it CACHED actually makes it work. Blink blink. Why does it work when cached and fail if it’s un-cached? I would have thought that running it un-cached involved fewer moving parts. Maybe I should just go to bed...
          • 18374
          • 69 Posts
          I’ve run into that problem many times on a current site I’m working on. The uncached snippet will not execute and the call is just displayed on the screen. Calling it cached and making the document uncacheable works. undecided

          The even stranger issue I was running into was that my snippets would work JUST FINE when called uncached. For weeks. Then all of a sudden one day I refreshed and bam, everything was borked. I never was able to figure anything out.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Mmm... I was looking at the parser code the other day, and I remember that I couldn’t see where it was pulling out un-cached Snippet calls -- I could see ’[[’ and ’]]’ references in the various regular expressions, but I didn’t see the ’[!’ versions ... maybe there are circumstances where the parser won’t pick up un-cached calls. There’s probably a reason for that, too...

            If you experienced sudden borkage, I’d have to ask what you were tweaking immediately prior.... and is there any way said tweakage could have resulted in said borkage?
              • 18374
              • 69 Posts
              I was modifying CSS files! Locally, then uploading them to the development server via TextMate/Transmit. I totally agree that had I been modifying something else the blame would obviously be on me.

              It may very well have been a change I made the previous day - but then why would it not take effect until the following afternoon? I’m in the habit of hard-refreshing on every refresh so I am almost positive I was not viewing an older version of the page.
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Man, that’s tough... the more I do coding, the more I have a 6th sense about those dangling-light-bulb interrogation like questions "WHERE HAVE YOU BEEN? WHAT LINE OF CODE DID YOU EDIT?!" because more often than not, something I changed had unintended consequences. Unit testing is a life-saver for these things.

                There are a lot of variables that contribute... e.g. page caching, snippet caching, and browser caching, but also the nature of the Snippet... what if the values the Snippet was reading changed between day 1 and day 2? Maybe the values wandered into some bunk area?

                Anyways, maybe this is all off-topic... why not make a post about your Snippet and we can take it up there?
                  • 20413
                  • 2,877 Posts
                  For me it doesn’t matter much though I prefer not using the document caching.
                  ...uncached at the "Page settings" tab (uncheck cacheable). Then it doesn’t matter if the snippet calls are [[cached]], because the entire document will be parsed on every request regardless.
                  And it is also the other way around - one must often call unchached snippets [!!] on cached docs...
                    @hawproductions | http://mrhaw.com/

                    Infograph: MODX Advanced Install in 7 steps:
                    http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                    Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                    http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • 5915
                    • 21 Posts
                    Whoo! Thanks. smiley I’m so lucky I caught this thread.

                    I thought I was going to have to write some extensive code because I have been writing all my snippets in exclamation points after I incurred parsing errors with another snippet.