MODX: How to find how many parents a document has?
Question by: highlander
Is there a way to know how many parents any given document has or, how far down the tree structure a document is located?
Solution by: opengeek
Updated by: pepebe to work with MODX REVO 2.2.0-pl2
Source: http://forums.modx.com/index.php?topic=18747.0;wap2
noOfParents snippet:
<?php
$id = isset($id) ? $id : $modx->resource->get('id');
$pids = $modx->getParentIds($id, 100, array('context' => 'de'));
return count($pids);