hi there, is there a way to know how many parents any given document has?
or, how far down the tree structure the document is?
if my tree structure is as follows:
-level 1 page
- level 2 page
- level 3 page
- level 4 page
-
level 5 page (current page)
- level 3 page
- level 2 page
eg: my code needs to know that the selected page above is at level 5 (or has 4 parents). is this possible?
thanks
EDIT: once again, solved my own problem. if anyone’s interested:
$thisId = (isset($id)) ? $id: $modx->documentIdentifier;
$arrDocParents[] = $thisId;
while (($pid = $modx->getDocument($thisId,'parent')) && ($pid['parent'] != 0)){
$thisId= $pid['parent'];
$arrDocParents[] = $thisId;
}
$countParents = count($arrDocParents);
unset($arrDocParents);
return $countParents;