We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17723
    • 221 Posts
    Hello,
    It would be very helpful to have a snipped that will return resources level. Is there any or what is the best way to get it in revo?
    Back in evo i had this snipped, but it doesn’t work in revo:
    <?php  
    if( !isset($resourceID) ) $resourceID = $modx->resource->id;
    if( !is_numeric($rootID) )$rootID = $modx->getOption('site_start');
    $parentIDs = $modx->getParentIDs($resourceID);
    array_unshift($parentIDs,$resourceID);
    return array_search( $rootID, $parentIDs );
      Lucas from AroundCyprus.net
    • The method is getParentIds() not getParentIDs(), but it should still work in Revolution.
        • 23018
        • 353 Posts
        Above source should have problems with Revo 2.1+.

        the snippet below works in Revo 2.2.0-pl2

        <?php
        
        $id = isset($id) ? $id : $modx->resource->get('id');
        $pids = $modx->getParentIds($id, 100, array('context' => 'de'));
        return count($pids);


        Note: If you sure about the context your snipet is running, you may remove the array() inside getParentIds().

        Regards,

        pepebe
          Homepage: pepebe.de | MODX snippets (and other stuff) at github: https://gist.github.com/pepebe