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
I need the parentID of block's Parent's Parent.
just wondering b4 I go digging ;-P
C
bump
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(); } }
I used this to display the grandparent link
Not sure if its the best way but it works.
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...
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...