We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Why does this snippet have to be called uncached in a cached page?

    Page Content
    [[CacheTest]]
    <p>[[+ph1]]</p>
    <p>[[+ph2]]</p>


    Snippet
    <?php
    $modx->setPlaceholder('ph1','Placeholder1');
    $modx->setPlaceholder('ph2','Placeholder2');


    If the snippet and the page are cached, there’s no output at all on reloading the page. I could swear that this wasn’t the case in earlier releases, but maybe I’m misremembering.
    (This is Revo 1.0.6-pl2)

    Do all snippets that set placeholders have to be uncached or in an uncached page?
      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
      • 22303 MODX Staff
      • 10,725 Posts
      If not, the placeholder only gets set on the first execution.
        • 3749
        • 24,544 Posts
        Quote from: OpenGeek at Jan 11, 2011, 10:40 AM

        If not, the placeholder only gets set on the first execution.

        Yes, but shouldn’t the rendered value of the placeholder from the first visit to the page get stored in the cached page where the placeholder was?

        It does not.

        As I said, the page above produces no output at all except for the first visit.
          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
          • 22303 MODX Staff
          • 10,725 Posts
          Now I’m confused amongst a few years worth of logic here—placeholders are never cached, and the code that prevents this has been there for quite a while. Removing this code does indeed solve the simple case, but I’m wondering what the consequences are wrt placeholder scope, output filters, etc. I’ll do some testing with this and see what happens...
            • 3749
            • 24,544 Posts
            Quote from: OpenGeek at Jan 11, 2011, 02:31 PM

            Now I’m confused amongst a few years worth of logic here—placeholders are never cached, and the code that prevents this has been there for quite a while. Removing this code does indeed solve the simple case, but I’m wondering what the consequences are wrt placeholder scope, output filters, etc. I’ll do some testing with this and see what happens...

            I’m confused too. I have an Evo version of the ThermX (fundraising thermometer) snippet that works fine in Evo with both the page and the snippet cached. In Revo -- same code except for the tag syntax -- it only works once, then the page is blank. I’m pretty sure that it worked in Revo when I first converted it, so I think something has changed lately that may break a number of existing pages.

            [Update]
            This is no help:

            [[CacheTest]]
            <p>[[!+ph1]]</p>
            <p>[[!+ph2]]</p>
              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