Created
May 9, 2011 13:14
-
-
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]]`]]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
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
Hi Mark,
I've had a little look at this again this morning.
It seems that part of the snippet is working. When I remove &input, I get the 'No relevant items found' messgae, and when I remove &tpl, I get the 'No template found message.
It just won't display anything when I do include both the input and the template. I've tried altering the template to just display the id, or the pagetitle, but with no luck.
Any thoughts would be much appreciated!