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:
//*** 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)

juddc
 

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.