-
-
Save Mark-H/962492 to your computer and use it in GitHub Desktop.
| <?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); | |
| ?> |
Did you select any items in your TV?
What do you get if you just output [[*relatedPages]] in your template or content?
Yep, have 4 items selected in the listbox.
When I just call the TV, I get a comma-delimited list of the ids I've chosen.
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!
I suspect you mistyped the chunk name.. It worked fine for me.
Updated the gist above with some better error reporting for chunks.
Oops, looks like some of the code got stripped out! I have used backticks on my snippet call, and the chunk is just a simple hyperlink, linking to the [[~[[*id]]]]