Skip to content

Instantly share code, notes, and snippets.

@rtripault
Created February 18, 2011 13:05
Show Gist options
  • Save rtripault/833625 to your computer and use it in GitHub Desktop.
Save rtripault/833625 to your computer and use it in GitHub Desktop.
<?php
// First fetch all the children of the current resource
$children = $modx->resource->getMany('Children');
// Check if there are any. If not, return false
if (!$children) { return false; }
// Check if there is a tpl set, if not return an error
$tpl = $modx->getOption('tpl',$scriptProperties,'');
if (!$tpl) { return 'No template given.'; }
// Start the output
$o = '<h2>[[*pagetitle]]</h2><ul>';
// Look through the results...
foreach ($children as $child) {
// ... fetching the needed info...
$out = array(
'id' => $child->get('id'),
'pagetitle' => $child->get('pagetitle'),
'menutitle' => $child->get('menutitle'),
'longtitle' => $child->get('longtitle'));
// ... and adding it to the output as placeholders in the chunk
$o .= $modx->getChunk($tpl,$out);
}
// Don't forget to close the list
$o .= '</ul>';
// Return the output
return $o;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment