We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 813 ☆ A M B ☆
    • 326 Posts
    I don’t know how to explain it, but using the placeholder method outlined by Bruno17, it’s working now. I don’t know what I changed, but I’m not going to complain wink It still only works if I call the snippet cached at the top of page, and I still can’t explain the "&" issue in Rich Text TVs, but this should get the job done. Thanks for the help, everyone! If this proves useful for anyone else down the road, please let me know!
      • 22303 MODX Staff
      • 10,725 Posts
      In Evo, placeholders are always cacheable if the page is. Thus, regardless of how you call the Snippet, the placeholders will only be set the first time and will be cached after that. In order to not cache placeholders, you must either make the page non-cacheable or return the content from a non-cacheable snippet.
        • 813 ☆ A M B ☆
        • 326 Posts
        That clears up that mystery. Thanks!
          • 813 ☆ A M B ☆
          • 326 Posts
          Since I already have some responses on this post, I’m going to add one more question that falls in line with the previous ones. Because I have to call the snippet cached, changes to the DB table aren’t showing up unless I clear the site cache. I’ve figured out how to do this automatically in my snippet, like so:

          function clearCache() {
              include_once "manager/processors/cache_sync.class.processor.php";
              $sync = new synccache();
              $sync->setCachepath("assets/cache/");
              $sync->setReport(false);
              $sync->emptyCache();
          }
          clearCache($sync);
          


          However, I don’t want this to fire all the time -- only when the placeholder is present on the page. Can I check this somehow and write it into an if statement? I thought the getPlaceholder API function would work, but it doesn’t do quite what I thought it did.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: aladage at Apr 15, 2010, 12:01 PM

            Because I have to call the snippet cached
            ??? You definitely shouldn’t call the snippet cached if the page is cacheable. Either make the page uncacheable, or call it uncacheable.
              • 813 ☆ A M B ☆
              • 326 Posts
              Quote from: OpenGeek at Apr 15, 2010, 04:16 PM

              Quote from: aladage at Apr 15, 2010, 12:01 PM

              Because I have to call the snippet cached
              ??? You definitely shouldn’t call the snippet cached if the page is cacheable. Either make the page uncacheable, or call it uncacheable.

              This is precisely my problem -- I don’t want to called the snippet cached, but it’s the only way it works for some reason (and I can’t call the page uncacheable). I have some other things going on on the page, though, and I think something might be conflicting. I’m going to tear it apart bit-by-bit and figure out what’s going on with my cache. I’ll post when I figure it out.
                • 813 ☆ A M B ☆
                • 326 Posts
                I’ve figured out the problem: it’s a conflict with PHx (duh -- I should’ve realized that). I’m having the same issue as this thread:

                http://modxcms.com/forums/index.php/topic,30928.0.html

                Because I’m using setPlaceholder in two snippets, the [+placeholders+] they generate is identical to the syntax PHx watches for. Fail.

                Turning off PHx is not an option, nor is calling all of my pages uncached. I assume that means my only option is to call my snippets cached, then? That’s not ideal, but I can make it work if I have to. Silly question, but there’s no way to set a placeholder using a different syntax, is there? How does Ditto/Wayfinder/Etc. use placeholders without creating an issue? Is it because I’m using them directly in the template and not in a &tpl chunk? I can switch things around and set up a &tpl, if that will solve the issues.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You can use a second snippet with $modx->getPlaceholder(’placeholderName’), which while a rather ugly workaround does work.
                    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
                    • 813 ☆ A M B ☆
                    • 326 Posts
                    Quote from: sottwell at Apr 19, 2010, 11:25 AM

                    You can use a second snippet with $modx->getPlaceholder(’placeholderName’), which while a rather ugly workaround does work.

                    Fantastic idea!!!! I’ve tried it and it does exactly what I need. You’re right that it’s not the most elegant option, but it definitely solves my caching issue. Thank you so much!