We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51474
    • 27 Posts
    I am having problem using my chunk to using getResources by passing snippet's dynamic ID to it.

    Using below's Chunk, my [[!getParentId]] successfully output 10 as a string.
    <ul>
    [[!getParentId]]
    [[getResources?
        &parents=`10`
        &showHidden=`1`
        &tpl=`areaHolder`
        &includeTVs=`1`
        &processTVs=`1`
        &depth=`0`
    ]]
    </ul>


    but when I wanted to insert my snippet inside my getResources, it seems fail to grab
    <ul>
    [[getResources?
        &parents=`[[!getParentId]]`
        &showHidden=`1`
        &tpl=`areaHolder`
        &includeTVs=`1`
        &processTVs=`1`
        &depth=`0`
    ]]
    </ul>


    May I know what did I do wrong?
    Should I use snippet to store my getResources instead of chunk? [ed. note: pohkit last edited this post 10 years, 9 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That is because you have an uncached snippet to provide its value to the cached snippet. The uncached snippet won't be processed right away, so its value won't be available to the outer cached snippet.

        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
        • 24732 ☆ A M B ☆
        • 300 Posts
        a cached snippet has no !

        uncached has !

        make sure the one you're pulling data from has !

        (which is exactly what Susan said but I tend to miss the obvious myself so wanted to explain in newbie terms. Susan rocks. )
          ________

          Anne
          Toad-in-Chief
          Red Toad Media - Web Design, Louisville KY
          Hear me tweet: http://www.twitter.com/redtoadmedia
          "Bring on the imperialistic condiments." - Rory Gilmore
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          To cache or not to cache can be difficult to figure out. Try to decide if that value is going to change when viewing the same page.

          If you are doing anything with the date or the time, such as for displaying the current date and time, this will change every time the page is viewed, so the snippet should be uncached.

          If a form is being posted to the same page, then the POST/GET values will change, so any form-processing snippet needs to be uncached.

          If different things are going to be shown to different users based on their login status, then these snippets need to be uncached. For example, a menu that will show a "Members" item to logged-in users should be uncached because if a logged-in user views the page and the menu is cached, then the next user to view the page is not logged in he'll still see that cached menu.

          In your case, the page's parents aren't going to change, so that getParentId snippet doesn't need to be uncached.
            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