We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53941
    • 3 Posts
    I have a set of pages that I am rendering programmatically using the renderResources plugin, called via $modx->runSnippet(). For the most part, everything works fine.

    However, there is one (important) template placeholder that is getting populated with information from the previously-rendered page. So, for example, if I render page 100 followed by 101, the pages will both render correctly, but the data intended for page 100 shows up on page 101 instead. In the snippet that is generating the needed data, I have added various debug output that shows the page does correctly generate the right data, but it doesn't populate it in the right page.

    I have tried unsetting and overwriting the placeholder and many other things to try to fix this. Other placeholders are working correctly. So far, no luck.

    This is a part of a large, fairly complex site, so it is possible that there is something else being cached somewhere that I am not aware of, but I have tried to find where that could be happening and so far no luck.

    Any thoughts, suggestions, or ideas?

    This question has been answered by BobRay. See the first response.

      • 3749
      • 24,544 Posts
      Is the snippet called uncached?

      [[!SnippetName]]
        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
        • 53941
        • 3 Posts
        Quote from: BobRay at Dec 01, 2017, 02:50 PM
        Is the snippet called uncached?

        [[!SnippetName]]

        I checked to be sure, but yes. It is the very first thing in the template file on the very first line, before any HTML or other code is rendered. It does not render any code itself (other than the debug code I added). It only sets variables and placeholders.
        • discuss.answer
          • 3749
          • 24,544 Posts
          Try making the placeholder(s) uncached:
          [[!+placeholderName]]
            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
            • 53941
            • 3 Posts
            Quote from: BobRay at Dec 01, 2017, 03:17 PM
            Try making the placeholder(s) uncached:
            [[!+placeholderName]]

            That was exactly the fix. I have been banging my head over this for a while. I knew that it was going to be something ridiculously simple. Thanks!
              • 3749
              • 24,544 Posts
              Glad I could help. Thanks for reporting back. smiley

              BTW, I didn't really expect this to work. Since the snippet is uncached, it should execute on every page load. Any placeholders set by the snippet should be reset as long as the snippet is above the placeholders on the page.

              The only thing I can think of is that because the snippet is called uncached, that delays its execution until after the first pass of the parser, which sets the placeholders from their current value, which hasn't been updated yet. Calling the placeholder uncached, delays its processing until a later pass when the new value is there. [ed. note: BobRay last edited this post 8 years, 9 months ago.]
                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