pepebe
1/24/2017 - 1:47 PM

Get all parents of a resource, return the id at a specific level.

Get all parents of a resource, return the id at a specific level.

<?php

/*Usage [[getParentIds? &level=`1`]]

*/

$level = !empty($level) ? $level : 1;

$arr = array_reverse($modx->getParentIds($modx->resource->get('id'), 10, array('context' => 'web')));

return $arr[$level];