How do you create a sub-menu that shows just the parent, not the whole top level?
Permalink
Hi There,
Still getting my head around autonav but am having trouble embedding a couple of sidebar menus in my templates.
Sub-menu one:
A menu that shows the parent first (highlighted) then all the pages under the parent at level 1.
Sub-menu two:
A menu that only shows the parent (highlighted).
I have this in my template:
And this in my sub_nav.php template:
I've played around with the various 'top' 'above' settings but they both seem to display the entire top level.
Should I be using a non-autonav call to grab the parent page, then using autonav to display the pages at the current level maybe?
New to c5 so sorry if this easy.
Cheers
ben
Still getting my head around autonav but am having trouble embedding a couple of sidebar menus in my templates.
Sub-menu one:
A menu that shows the parent first (highlighted) then all the pages under the parent at level 1.
Sub-menu two:
A menu that only shows the parent (highlighted).
I have this in my template:
<ul class="s-nav"> <?php $autonav = BlockType::getByHandle('autonav'); $autonav->controller->orderBy = 'display_asc'; $autonav->render('templates/sub_nav'); ?> </ul>
And this in my sub_nav.php template:
<?php defined('C5_EXECUTE') or die("Access Denied."); $bt->controller->displayPages = 'above'; $aBlocks = $controller->generateNav(); $c = Page::getCurrentPage(); $nh = Loader::helper('navigation'); $isFirst = true; foreach($aBlocks as $ni) { $_c = $ni->getCollectionObject(); if (!$_c->getCollectionAttributeValue('exclude_nav')) { $target = $ni->getTarget(); if ($target != '') { $target = 'target="' . $target . '"'; } if ($ni->isActive($c) || strpos($c->getCollectionPath(), $_c->getCollectionPath()) === 0) {
Viewing 15 lines of 42 lines. View entire code block.
I've played around with the various 'top' 'above' settings but they both seem to display the entire top level.
Should I be using a non-autonav call to grab the parent page, then using autonav to display the pages at the current level maybe?
New to c5 so sorry if this easy.
Cheers
ben

Yeah, I would pull the current page's parent, then add a link using that. Something like:
Beautiful - thanks mate.
For my own reference (incase I forget later on) I put this extra call above the autonav call in the page template.
For my own reference (incase I forget later on) I put this extra call above the autonav call in the page template.
Yeah, that makes sense to me.
The only issue is that when this template is used on the parent page, it displays home instead if it's own page name.
Is there way to create a flexible menu that could be used on both parent pages as well as child pages?
Is there way to create a flexible menu that could be used on both parent pages as well as child pages?