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

    I am a newbie to MODX and wondering if you can call a snippet from a chunk and output the results of the snippet into the same chunk's placeholders. I am using getResources with the following parameters in MyChunk:

    [[getResources? &parents=`-1` &resources=`6` &tpl=`MyChunk`]]

    <h1>Hello World [+pagetitle]]</h1>


    Sorry if it has been asked already or it is in the documentation.

    Regards,

    gergiusz
      • 3749
      • 24,544 Posts
      If I'm understanding you, I don't think it will work. getResources will replace the placeholder values when it retrieves the chunk. It should leave unrecognized placeholders alone, but when your snippet sets the placeholders, they are not actually replaced until later, so every resource retrieve will have the value from the last time the snippet runs.

      You can call a snippet in a chunk, but usually only to replace the snippet tag with the return value of the snippet.


      Can you explain why you need a separate snippet, rather then just letting getResources do the replacements?


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html



        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
        • 40552
        • 2 Posts
        Hi,

        Thanks for the reply.

        I was actually getting acquainted with MODX last week and wondered if you can do it. You wouldn't need to have snippet calls in the template as it would purely consist of chunks. This way you would only need to change the chunks in case something changes so all your templates which uses the same chunks would be updated.

        Anyway, the framework is rocking I really like the feature for using the static file includes for your resources as it works superbly with an IDE and makes development rapid.

        Thanks,

        gergiusz