Skip to content

Instantly share code, notes, and snippets.

@Mark-H
Created May 9, 2011 13:14
Show Gist options
  • Select an option

  • Save Mark-H/962492 to your computer and use it in GitHub Desktop.

Select an option

Save Mark-H/962492 to your computer and use it in GitHub Desktop.
Simple snippet (output filter) for MODX Revolution related items. Call as [[snippetname? &tpl=`chunkname` &input=`[[*your-comma-delimited-id-tv]]`]]
<?php
if ($input == null) { return 'No relevant items found.'; }
$tpl = $modx->getOption('tpl',$scriptProperties,null);
if (($tpl === null) || (!$modx->getChunk($tpl))) { return 'No template found'; }
$ids = explode (',', $input);
foreach ($ids as $a => $key) {
$document = $modx->getObject('modResource', array(
'published' => 1,
'id' => $key));
if ($document) {
$output[] = $modx->getChunk($tpl,$document->toArray());
}
}
return implode(', ',$output);
?>
@Mark-H

Mark-H commented May 11, 2011

Copy link
Copy Markdown
Author

I suspect you mistyped the chunk name.. It worked fine for me.

Updated the gist above with some better error reporting for chunks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment