Auto Nav (show parent / child only with a specific attribute value)

Permalink
Hi,

I'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?

1 Attachment

 
hutman replied on at Permalink Reply
hutman
Just to be clear, you are trying to setup an autonav where the only dropdowns that show are under parents who have the main_nav checkbox checked in the page attributes? Is that correct?
zlitrox replied on at Permalink Reply
That is correct!
hutman replied on at Permalink Reply
hutman
The easiest way to do this I think would be to add a class to the parent and adjust your javascript (or css) for the dropdown to only show the subnav if the parent has that class.

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.
zlitrox replied on at Permalink Reply
I prefer to do it "the right way" not hidden by css.

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.