We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17833
    • 28 Posts
    First Question: What is the difference between getChunk() and putChunk()?


    Secondly, I was hoping to use chunk for a web report i’m creating.  I thought that i could create a chunk using placeholders, and then reiterate through a loop, inserting the chunk w/ placeholders each iteration.  but this just repeats the chunk using the last values for the placeholder in each occurance.  is there a way of doing it this way?
    • What is the difference between getChunk() and putChunk()?
      putChunk() is deprecated and just calls the getChunk() function - putChunk() is only there for reasons of backwards compatibility.

      The reason i ask is i have a snippet that populates a dropdown box and then creates a placeholder that equals that dropdown box. It is then supposed to load the chunk. Unfortunately, when the page is rendered, the placeholder is missing. the rest of the chunk displays properly, and if i add the placeholder to the page manually, it shows properly.
      Any chance of a code sample? It would really help to point you in the right direction if I could see what you have so far smiley

      I thought that i could create a chunk using placeholders, and then reiterate through a loop, inserting the chunk w/ placeholders each iteration. but this just repeats the chunk using the last values for the placeholder in each occurance. is there a way of doing it this way?
      Are you using $modx->parseChunk() on each iteration or just outputting the unparsed chunk? You will need to use the former to insert the correct values at each iteration of the loop.

      Hope that helps,
      Garry
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 17833
        • 28 Posts
        Thanks Garry

        I solved the first problem it was a ... typo tongue

        I’ll give that parseChunk() a go now. I didn’t find it in the api quick reference, but i see it now in the document.parser.class.inc.php

        thanks again.