Thanks for your answer.
Yes, you’re right. I didn’t explain my problem correctly (or I am missunderstanding the caching system). My problem is related to
$this->_processed which seems to be connected somehow to the caching of a chunk’s output.
Here is what I want to do:
1. Load an existing chunk via $chunk = $modx->getObject(’modChunk’,...)
2. Set it to non cacheable: $chunk->setCacheable(false);
3. Loop through an array which contains different values for the placeholders defined in the chunk and proccess the chunk for each array element. Something like this:
<?php
$chunk->setCacheable(false);
$output = '';
foreach($xyzs as $xyz) {
$output .= $chunk->process($xyz);
}
This doesn’t work because in the process method of
modChunk $this->_processed is set to
true without checking/invoking
isCacheable() before (but this is done in modElement).
There is no public method available to set $this->_processed = false in order to recreate the output with the new placeholder values. So you are not able to process a single chunk object more than once with different placeholders(?). I was only able to do this by creating a new chunk object with the some content data:
<?php
$output = '';
$chunkData = $chunk->toArray('', true);
foreach($xyzs as xyz) {
$chunk = $modx->newObject('modChunk');
$chunk->fromArray($chunkData, '', true, true, true);
$output .= $chunk->process($xyz);
}
I’m wondering if this is a clean way or if I’m not understanding the caching system....
I hope this explanation is clearer.
Thanks,
Jakob