We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46950
    • 86 Posts
    Here https://github.com/bezumkin/AjaxSnippet is a short description of this snippet but the parameter &parents is not described even in its descriptions in Russian which are some longer. Here http://artinox-td.ru/modx/index.php?id=3 I put this piece of code:

    [[AjaxSnippet?
        &snippet=`getResources`
        &parents=`0`
        &tpl=`@INLINE <p>Some info</p>`
        &as_mode=`onclick`
        &as_trigger=`Click me!`
    ]]   
    


    You can see the reference "Click me!" in the left part of the page. I cannot understand why, when I click it, FIVE copies of the line "Some info" appear! (I'd like to see only one.)
      • 3749
      • 24,544 Posts
      The &parents value is passed on to getResources, so you can look at it's documentation. Basically it tells getResources where to start looking for resources to aggregate. The value is the resource ID to look under. Setting it to 0 starts at the top of the Resource Tree. The &tpl property is also for getResources and is for displaying information about each resource found.

      5 is the default limit for getResources. You can change it with the &limit property (0 for unlimited). Get resources is getting the first five resources under the 'web' folder in the tree (since you specified 0 for the parents field). Since you don't have any placeholders in the &tpl value, you're not seeing any information about the five resources it's getting.

      Try changing the tpl line to this:

       &tpl=`@INLINE <p>Some info: [[+pagetitle]]</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
        • 46950
        • 86 Posts
        Thank you very much, Bob! Seems now I understand the way this snippet works, much better. Before it I could not realize that the parameter &parents refers to the snippet getResources. Though the parameter &useWeblinkUrl (I found it in on of examples) is still mysterious to me.
          • 3749
          • 24,544 Posts
          As I understand it, the point of AjaxSnippet is to have a snippet that runs when you click on a button, rather than when the page loads. It will run any snippet and I'm fairly sure it will pass any properties that are not its own on to the snippet. I'm afraid I don't even have a guess about the &useWeblinkUrl property.
            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
          • That one determines whether to use the URL to a weblink, or to use the URL that the weblink contains.
              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