Parent section name (w/ multi-tier)
Permalink 1 user found helpful
I looked around the forums and found the way to embed the section name within a template is to use So even if your on a subpage of a section, the main section name is still displayed. My issue is, if someone goes three levels deep, then the second pages name is displayed as the section name. Is there a way to prevent that? So basically I always want to show the top level parent name, no matter how many levels deep you are. Thanks.
<?php $page = Page::getByID($c->getCollectionParentID()); print $page->getCollectionName();?>
I'm also looking for a solution to this problem, anyone? there must be a way?
You could set up a loop where you navigate up the tree of parents until you find one where there is some indicator that you have reached the top page of the section (e.g. a page attribute has been set).
Here is the answer:
Taken from this post,http://www.concrete5.org/community/forums/customizing_c5/nested-pag...
Cheers.
<?php global $c; $nh = Loader::helper('navigation'); $cobj = $nh->getTrailToCollection($c); ?> <?php $rcobj = array_reverse($cobj); if(is_object($rcobj[1])) { $pID = $rcobj[1]->getCollectionID(); $page = Page::getByID($pID); $title= $page->getCollectionName(); }else{ $title= $c->getCollectionName(); }
Viewing 15 lines of 17 lines. View entire code block.
Taken from this post,http://www.concrete5.org/community/forums/customizing_c5/nested-pag...
Cheers.