We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17866
    • 3 Posts


    Situation:


    I’ve created snipped called "greeting"

    
    $modx->setPlaceholder('msg', 'Hello world!');
    
    


    When i call snippet in template like:

    
    [[greeting]]
    
    [[+msg]]
    
    


    Everething works, i get Hello world! message on the screen.

    BUT! When i reload the page, message disappears...

    If i update snippet code, again it appears, and disappears after pager refresh.

    I tried on Windows & Linux servers no diff, am i doing something wrong?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Call the snippet uncached. If the page is cached, it’s not going to run the snippet to set the placeholder.
        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
        • 17866
        • 3 Posts
        Damn it i’v read about this but tryied it like [[!+msg]] not like [[!greeting]], my bad sorry...
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: MaD at Jul 23, 2010, 12:55 PM

          Damn it i’v read about this but tryied it like [[!+msg]] not like [[!greeting]], my bad sorry...
          In this case, you would need both, otherwise, the placeholder will be cached after the first execution of the Snippet.
            • 25663 MODX Staff
            • 12,272 Posts
            If you’re just updating it periodically, you can do so with just a chunk and skip the snippet part (though I suspect you have a bit more going on in your snippet, so it’ll be needed):

            [[$message?msg=`Hello world!`]]


            And your actual message chunk would be:

            <div class="notice">
                <p>[[!+msg]]</p>
            </div>


            It’s a simple little thing but it’s already helping me figure out ways to use fewer templates and make more flexible and robust sites in Revo than I ever could have in Evo.
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me