Forum
Pages Navigation: Using Nav Group doesn't display current page active class
We have used the perch_pages-navigation array to display the site navigation and this works great. However, for two sub navs we have setup Navigation Groups. However, when used it displays links OK, but doesn't recognise current page and change class to active state?
Assume they both used the same "item" template?
<li<perch:if exists="current_page"> class="active"</perch:if>>
Works:
<?php perch_pages_navigation(array(
'levels' => 1,
)); ?>
Doesn't work:
<?php perch_pages_navigation(array(
'navgroup' => 'portrait-nav',
)); ?>
Thanks for any advice!
Does your nav group have the correct page structure? Remember that the tree is taken from the nav group at that point, not from the default page tree.
Not sure I understand fully what you mean...
I created the Navigation group, then ticked the pages I wanted to show (in page options) which is 3 pages under one of the main sections AND the main section page itself. So one of the links (pages) is in the main nav as well.
Which version are you running?
What happens if you add
<perch:showall />
to your template?Perch 2.4.9
Adding "showall" to item template in navigation I get a list of the pages in tables with info like: ID, perch_page_path etc etc.
Curiously, the "pageTreePosition" for all sub nav items is 000-000? Whereas in the main nav generated not with nav groups, it's correctly listing... 000-001, 000-002, etc.
Have you arranged the nav group into a hierarchical structure, or is it all flat?
Nav group is flat.
I tried removing the top level page from sub nav in nav group but no change, active class does not show.
If the group is flat then it's correct that the
pageTreePosition
doesn't have a hierarchy. If you've not reordered them, it won't have an order either.OK so, if that is not the issue, why is the active class not changing? Is this a bug with Nav Groups?
Do you have a test case I could use to reproduce it?
In latest Perch version, just try creating a few sub pages in a navigation linked to a top level navigation item that always displays on page and is generated using a page array (below) - called from a php include page.
This is my navigation item template:
Array for top level navigation:
Has there been no other issues with nav groups??
OK, activate state just not working for any sub navs, even using arrays. I will double check CSS now, there must be something astray here...
We'll see if we can reproduce it.