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,
    I would need to be able to use a value of level that I’m currently in?

    Do You know how to achieve it in Revo?

    Luke
      Lucas from AroundCyprus.net
      • 13218
      • 134 Posts
      Hi Luke,
      assuming i understood correctly you could use this as a snippet:
      <?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 );


      you call it like this:
      [[!getResourceLevel? &resourceID=`9` &rootID=`1`]]

      resourceID is the ID of the document you want to get the level of. default is the current resource
      rootID is the ID of the document that is the starting point of your tree / level 0. defaults to site_start

      it returns 0 if rootID === resurceID, 1 if rootID is first parent etc, and false if rootID is not a parent of resourceID

      *marc
        @itWilllBeOK
        • 17723
        • 221 Posts
        Surely that is OK !

        Thank You very much!

        That snipped should be in repository.

        Luke
          Lucas from AroundCyprus.net