Is there a way to do this? I want to get the depth of the current document.
I’ve been looking at various options, getChildIds etc. I can’t figure it out.
I want to display a sub navigation if a page is at a certain depth.
Evolution 1.0.0
Many thanks
I think you’ll need a custom snippet using $modx->getParent().
Something like this (untested):
<?php
$level = 1;
$currentId = $modx->documentObject['parent'];
while ($currentId) { // quit when parent id is 0
$currentId = $modx->getParent($currentId,1,'parent');
$level++;
}
// at this point, $level should be the level of the current document
?>
Note: All docs in the chain must be published for this to work.
Glad you got it working. Thanks for posting the working version.