ParentID of a ParentID of a block

Permalink
anyone done this?

I need the parentID of block's Parent's Parent.

just wondering b4 I go digging ;-P

C

RadiantWeb
 
RadiantWeb replied on at Permalink Reply
RadiantWeb
bump
Tony replied on at Permalink Reply
Tony
can't you just walk up the tree like this:

global $c;
$parentPageID = $c->getCollectionParentID();
$parentPage = Page::getById($parentPageID);
if(is_object($parentPage)){ 
     $parentParentPageID = $parentPage->getCollectionParentID();
     $parentParentPage = Page::getById($parentParentPageID);
     if(is_object($parentParentPage)){
          $parentParentParentPageID = $parentParentPage->getCollectionParentID();
     }
}
TheRealSean replied on at Permalink Reply
TheRealSean
I used this to display the grandparent link

Not sure if its the best way but it works.

$nh = Loader::helper('navigation');
$_c = $nh->getTrailToCollection($c);
$page = Page::getByID($_c[0]->getCollectionParentID());
print $page->getCollectionName();


I have realised this only works at the 3rd level, but it could be possible to do a foreach on the results of $_c here? then work out position of the parent based on its index?

also now wrapped it within the is_object to stop it complaining when editing the page_type defaults
http://www.concrete5.org/index.php?cID=56694...