Skip to content

Instantly share code, notes, and snippets.

@pepebe
Created January 24, 2012 13:05
Show Gist options
  • Save pepebe/1670095 to your computer and use it in GitHub Desktop.
Save pepebe/1670095 to your computer and use it in GitHub Desktop.
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);
@pepebe
Copy link
Author

pepebe commented Jan 24, 2012

Sidenote: You may remove the paramter part (array(...) if you are content with your current context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment