We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21916
    • 8 Posts
    Hi all,
    Im having this doubt when is the best way to parse a chunk (performance...).

    You have the same result doing this:

    1.
    $params[’place’]=’hello’;
    return $modx->parseChunk(’chunk’, $params ,’[+’ , ’+]’ );


    2.
    $modx->setPlaceholder(’place’ , ’hello’);
    return $modx->getChunk(chunk);



    chunk:
    [+place+] world!

    Is one way better then the other? What are the differences?
    Appreciate any advice.

    Nuno










      • 22303 MODX Staff
      • 10,725 Posts
      In Revo there is not much difference, other than the placeholders with parseChunk are only set for the scope of the call.

      In Evo, parseChunk uses str_replace to directly replace the placeholders, while setting the placeholder with the API and calling getChunk will replace the placeholders on the next pass of the parser (and the placeholders will be set for the entire page scope).