Well you sure can do those thing with str_replace(), but there is an API provided by MODx to do those kind of thing, which sometimes it works really well for me.
Check setPlaceHolder & getPlaceHolder API
You also want to check mergePlaceholderContent & MergeChunkContent API for integrating it with the chunk template that you’ve created.
Here is a little overview for each of them
function setPlaceholder($name,$value)
This API will basically store the $value variable into placeholders array with the associated key name from the given $name. The placeholder array, later can be applied to substitute a string template that has a special MODx placholder with the format of "[+key_name+]", without the quote.
function getPlaceholder($name)
This is the opposite API of sePlaceHolder, which it will return the value of placeholder array with the given $name as the key name.
function mergePlaceholderContent($content)
This function will combined the placeholders array that was set earlier (setPlaceholder) with the given string template, which was passed on to $content. It will replace "[+key_name+]" symbol in the template with the value on the array with the same key name. The rest of the placeholders symbol that are not associated with everything will be remove and substituted with empty string.
function mergeChunkContent($content)
This API will fetch a chunk based on their name, when it was stored inside the manager. We need to pass on a string with the format as when we are included chunk to the template or content "{{chunk_name}}", without the quote.
I think that’s all that you need to sstart rolling right now. Have MODx-ing with your new set of toy.