tnx a lot opengeek!
I guess I don’t understand how getMany works then.
with getCollection it was easy!
if anyone wants to see them:($categorie is a TV)
shows the children or the bottom layer
<?php
if ($categorie<>0){
//get current id of the current page to get the children
$currentResource = $modx->resource;
$currentid=$currentResource->get('id');
//get the children
$lastcriteria = $modx->newQuery('modResource');
$lastcriteria->where(array('parent' => $currentid,));
$lastcriteria->sortby('pagetitle','ASC');
$lastlijst = $modx->getCollection('modResource', $lastcriteria);
if (count($lastlijst)<>0){
$last=$currentResource->get('pagetitle').": ";
foreach ($lastlijst as $lasteen){
$last=$last."<a href=\"".$modx->makeUrl($lasteen->get('id'))."\">".$lasteen->get('pagetitle')."</a> ";
}
}
else{
//zoek de parent van de huidige pagina en toon daarvan de kinderen
$parentResource = $currentResource->getOne('Parent');
$parentid=$parentResource->get('id');
$lastcriteria = $modx->newQuery('modResource');
$lastcriteria->where(array('parent' => $parentid,));
$lastcriteria->sortby('pagetitle','ASC');
$lastlijst = $modx->getCollection('modResource', $lastcriteria);
foreach ($lastlijst as $lasteen){
$last=$last."<a href=\"".$modx->makeUrl($lasteen->get('id'))."\">".$lasteen->get('pagetitle')."</a> ";
}
}
return $last;
}
?>
shows the parents or the top layer
<?php
if ($categorie<>0){
$currentResource = $modx->resource;
$parentid=$currentResource->get('parent');
if (isset($parentid)){
$parentResource = $modx->getObject('modResource',array(
'id' =>$parentid));
if (isset($parentResource)){
$secondparentid=$parentResource->get('parent');
if (isset($secondparentid)){
$secondparentResource = $modx->getObject('modResource',array(
'id' =>$secondparentid));
if (isset($secondparentResource)){
$tv = $modx->getObject('modTemplateVar',array('name'=>'categorie'));
if ($tv->renderOutput($parentResource->get('id'))<>0){
$kinderenvan=$secondparentid;
$first=$first.$secondparentResource->get('pagetitle').": ";;
}
else {$first=$first."Categorieën : ";$kinderenvan=3;}
}
else {$first=$first."Categorieën : ";$kinderenvan=3;}
}
else{$first=$first."Categorieën : ";$kinderenvan=3;}
}
else{$first=$first."Categorieën : ";$kinderenvan=3;}
}
else{$first=$first."Categorieën : ";$kinderenvan=3;}
}
else{$first=$first."Categorieën : ";$kinderenvan=3;}
$firstcriteria = $modx->newQuery('modResource');
$firstcriteria->where(array(
'parent' => $kinderenvan,
));
$firstcriteria->sortby('pagetitle','ASC');
$firstlijst = $modx->getCollection('modResource', $firstcriteria);
foreach ($firstlijst as $firsteen){
$first=$first."<a href=\"".$modx->makeUrl($firsteen->get('id'))."\">".$firsteen->get('pagetitle')."</a> ";
}
return $first;
?>
I guess they are not the best way,
but they work!