Hi, this is weird. I'm pretty sure that
$modx->resource->getMany('Children') should return children of the current resource, and
$modx->resource->get('id') should return the ID of the current resource, but for some reason on my development project, this is not the case. I get the children of ID#1 instead, even with a simple test:
<?php
// Get the children
error_log(print_r($modx->resource->get('id'), 1)); // prints 1
$children = $modx->resource->getMany('Children'); // returns children of 1
if ($children) {
// Parse children
$retVal = '<ul>';
foreach ($children as $child) {
$retVal .= '<li>Resource ' . $child->get('id') . ', child of resource ' . $child->get('parent') . '</li>';
}
$retVal .= '</ul>';
return $retVal;
}
?>
Output, when run on page #3:
- Resource 15, child of resource 1
- Resource 16, child of resource 1
- Resource 17, child of resource 1
- Resource 18, child of resource 1
Surely I've done something wrong. Help?
MODX Revolution 2.2.5-pl (traditional)