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?
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?
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?
That is correct!
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
This will add the class "show-dropdown" to the classes on any li elements that have your attribute checked.
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.
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.
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.