Add parent to second-level in Autonav?
Permalink
Hi All,
Just like it says - Any way to add the parent of a second-level page into the autonav? I found some code and can fake it, but obviously I won't be able to style the nav-path / nav-path-selected if I land on the parent page.
So I'm wondering if it can be shoved in there or something. Any thoughts?
Here is what I'm currently using in my autonav template:
Just like it says - Any way to add the parent of a second-level page into the autonav? I found some code and can fake it, but obviously I won't be able to style the nav-path / nav-path-selected if I land on the parent page.
So I'm wondering if it can be shoved in there or something. Any thoughts?
Here is what I'm currently using in my autonav template:
//*** Step 2 of 2: Output menu HTML ***/ $c = Page::getCurrentPage(); //If not on the home page if ($c->cID > 1) { $nh = Loader::helper('navigation'); $arrTrail = array_reverse($nh->getTrailToCollection($c)); $objHomePage = $arrTrail[0]; // Home page object; //If we're on a top-level page then our $arrTrail array will only have the home page object //so we test to see if its Page object exists $objTopPage = is_object($arrTrail[1]) && $arrTrail[1] instanceof Page && !$arrTrail[1]->error ? $arrTrail[1] : $c; //If we have a valid top page Page object we retrieve $title = $objTopPage->getCollectionName(); $pageHandle = $objTopPage->getCollectionHandle(); $url = $nh->getLinkToCollection($objTopPage); //Print parent (if on one of its subpages)
Viewing 15 lines of 28 lines. View entire code block.