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 pageif($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)
//*** Step 2 of 2: Output menu HTML ***/$c= Page::getCurrentPage();//If not on the home pageif($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)$ultiParent='<a class="ultiParent" href="'.$url.'">'.$title.'</a>';}//show ultimate parent page name and linkecho$ultiParent;foreach($navItemsas$ni){echo'<a href="'.$ni->url.'" target="'.$ni->target.'" class="'.$ni->classes.'">'.$ni->name.'</a>';if($ni->hasSubmenu){echo'<ul>';//opens a dropdown sub-menu}else{echo'</li>';//closes a nav itemechostr_repeat('</ul>',$ni->subDepth);//closes dropdown sub-menu(s) and their top-level nav item(s)}}
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.
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.