Auto Nav (show parent / child only with a specific attribute value)
PermalinkI'm trying to create a dropdown menu where i want to present a few links that has been selected through admin (i've created a attribute checkbox with name main_nav).
I can get the parent pages to show in the menu but sub pages are not shown in dropdown if i check for the attribute 'main_nav' (they don't have that in admin). Is it possible to check if their parent has that attribute and show them?
It would be great if someone can show som example code for this usage.
I've similar structure to this:
- Parent 1 (page that has attribute main_nav checked)
- Child 1 (page that does not have attribute main_nav checked)
- Child 2 (page that does not have attribute main_nav checked)
- Child 3 (page that does not have attribute main_nav checked)
- Parent 2 (page that has attribute main_nav checked)
- Parent 3 (page that has attribute main_nav checked)
- Child 1 (page that does not have attribute main_nav checked)
- Child 2 (page that does not have attribute main_nav checked)
- Parent 4 (page that has attribute main_nav checked)
- Child 1 (page that does not have attribute main_nav checked)
- Parent 5 (page that does not have attribute main_nav checked)
- Parent 6 (page that does not have attribute main_nav checked)
- Parent 7 (page that does not have attribute main_nav checked)
- Parent 8 (page that does not have attribute main_nav checked)
What i want to do is show Parent 1, 2, 3 and 4 in menu first level menu and selected/hovered parents children in dropdown when hovering parent link.
Is this possible to achieve in Concrete 5?

You can add the class by adding this to your autonav view file
if ($navItem->cObj->getAttribute('main_nav')) { $classes[] = 'show-dropdown'; }
This will add the class "show-dropdown" to the classes on any li elements that have your attribute checked.
Is there any chance you could point mer in the right direction?
I'm a programmer so i know how to code, but that template for autonav is not near logical for me.