$boxids = $modx->getDocumentChildren($parentID,1,0,'id,pagetitle');
$modx->getChildIds();
$children = $modx->getCollection('modResource', array('parent' => $parentId));
foreach ($children as $child) {
$pagetitle = $child->get('pagetitle');
$id = $child->get('id');
}
$children = $parentObj->getMany('Children');$children = $modx->resource->getMany('Children');$query = $modx->newQuery('modResource');
$query->select($modx->getSelectColumns('modResource','modResource','',array('id','pagetitle','parent')));
$query->where(array(
'parent' => $parentId,
));
$children = $modx->getCollection('modResource',$query);Here are two quick and dirty methods:
$children = $modx->getCollection('modResource', array('parent' => $parentId)); foreach ($children as $child) { $pagetitle = $child->get('pagetitle'); $id = $child->get('id'); }
If you already have the parent object (for example if it's the current resource), you can replace the first line with this:
$children = $parentObj->getMany('Children');
or
$children = $modx->resource->getMany('Children');
You can refine this by using $modx->newQuery() and $modx->getSelectColumns() to restrict the fields returned to just the id and pagetitle (but be sure to include the parent field if you're using the getCollection() version). The code above may be fast enough, though.
$query = $modx->newQuery('modResource'); $query->select($modx->getSelectColumns('modResource','modResource','',array('id','pagetitle','parent'))); $query->where(array( 'parent' => $parentId, )); $children = $modx->getCollection('modResource',$query);
$sql = "SELECT id, pagetitle FROM modx_site_content WHERE parent = " .$parentID. " AND published=1 AND deleted=0"; $result = $modx->query($sql); $boxids = $result->fetchAll(PDO::FETCH_ASSOC);
$parentObj = $modx->getObject('modResource', array('id' => 189));
$children = $parentObj->getMany('Children');
$parentObj = $modx->getObject('modResource', array('id' => 189));
$children = $parentObj->Children;
// or for the current resource
$children = $modx->resource->Children;