getResources or wayfinder, both can do that.
If you need to create a navigation or something like that, you would prefer to use wayfinder.
For other listings, getResources.
I've tried them but I can't figure out how to do it!
--
André
<ul>
[[getResources? &parents=`[[*id]]` &tpl=`yourTplchunk`]]
</ul>
Or, if you prefer a custom-snippet, something like that should do it.
Modified version of Marks one:
<?php
$tpl = $modx->getOption('tpl', $scriptProperties, false);
$parent = $modx->getOption('parent', $scriptProperties, $modx->resource->get('id'));
$o = $modx->getOption('default', $scriptProperties, '');
// Check if there is a tpl set, if not return an error
if (!$tpl) {
return 'No template given.';
}
// First fetch all the children of any resource
$classname = 'modResource';
$c = $modx->newQuery($classname);
$c->where(array('parent' => $parent));
if ($children = $modx->getCollection($classname, $c)) {
// 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;
[ed. note: Bruno17 last edited this post 14 years, 2 months ago.]
try:
[[getEvents? &parent=`16` &tpl=`getChildrenTpl`]]
or:
<ul>
[[getResources? &parents=`[[*id]]` &tpl=`yourTplchunk` &showHidden=`1`]]
</ul>
forgot:
$classname = 'modResource';
added it above.
if you want all the childs of 16 then:
<ul>
[[getResources? &parents=`16` &tpl=`yourTplchunk` &showHidden=`1` &limit=`0` &depth=`1`]]
</ul>
and you will need your own chunk for 'yourTplchunk'
see also:
http://rtfm.modx.com/display/ADDON/getResources
Now both of them work! Thank you very much for your help Bruno!!! =)
--
André