Name:
parseChunk
Description:
returns a chunk with any placeholders inside it populated with your own values
Syntax:
parseChunk($chunkName, $chunkVars, $prefix, $suffix);
Parameters:
* chunkName - name of the chunk
* chunkVars - an associative array of variables
* prefix & suffix- the strings which wrap around any placeholders in the chunk
(defaults to {placeholder} , NOT {+placeholder+} !!)
Example of use:
if we have a chunk called ’anecdote_chunk’, like this:
<strong>The tramp made friends with a {+colour+} {+smell+} {+beast+}.</strong>
<img src='images/{+colour+}_{+smell+}_{+beast+}.jpg'>
Then your snippet can access and populate the chunk...
$vars=array();
$vars['beast']='pig';
$vars['colour']='yellow';
$vars['smell']='cheesy';
$output = $modx->parseChunk('anecdote_chunk', $vars, '{+', '+}' );
return $output;
Notes
parseChunk makes use of $modx->getChunk($chunkName) which you might find more useful