Blog Sections Open
Using a TV Value as the documents Source for Ditto
When a TV stores a comma-separated list of resource IDs, Ditto can use it as the source list — but you need to read the TV from the correct document first.
This pattern is useful for “featured products”, “top picks”, or “hits” blocks. One document stores a list of resource IDs in a TV, and Ditto should render those specific resources everywhere else.
The key detail
If you call Ditto with &documents=`` on another page, it may not work because the TV is being read from the current resource instead of the dedicated source document.
Practical fix
First fetch the TV from the document that owns the list, then pass that value into Ditto’s &documents parameter.
$hits = $modx->getTemplateVarOutput('hit', $sourceDocId);
echo $modx->runSnippet('Ditto', array(
'documents' => $hits['hit'],
'tpl' => 'hit-tpl'
));
Wrapping Every Three Ditto Items for a Carousel Layout
Carousel markup usually needs grouped output, so treat every third Ditto item as a boundary for opening and closing the wrapper block.
Attaching Multiple Images to an eForm Submission
Multiple file attachments in eForm are possible, but the form and mail-processing layer both need to be structured for repeated files instead of a single upload field.