Filter Autonav by A Different Attribute

Permalink
Right now, it seems the only thing I can do with an AutoNav is use the exclude_from_nav attribute to filter out pages I don't want.

However, I need to filter IN pages that I want.

In this case, I have 3 navigation bars on the page.

The Main Nav

A "header nav" with shows things likes About Us, Contact Us, Support, etc.

A Footer Nav, which houses the Site Map, Privacy Policy and Newsletter Signup pages.

I created an attributes for "top_nav_item" and "footer_nav_item"

I need the autonav to ONLY pull in pages that match one of those attributes.

How can I do this.

EDIT:
Alternatively, I could use a Page List, but I would need a way to apply Nav Selected and Nav Path Selected attributes in the output so it would function like a navigation.

leinteractive
 
planist1 replied on at Permalink Reply
planist1
I don't remember exactly where I pulled some of the code from but I believe a majority of it came from Jordan Lev's article here: http://c5blog.jordanlev.com/blog/2011/12/customizing-the-autonav-te...

Instructions
If you haven't already create the following folder:

your_root_install_folder/blocks/autonav/templates (not in the concrete folder)

create a file in there called header_nav.php and put the following in the file. (you may need to tweek it a little to meet your needs, but it might provide a good starting point)

<?php
//NOTE: For extra functionality, you can add the following page attributes (via Dashboard -> Pages and Themes -> Attributes):
//
// 1) Handle: replace_link_with_first_in_nav
// Type: Checkbox
// Functionality: If a page has this checked, clicking on it in the nav menu will go to its first child (sub-page) instead.
//
// 2) Handle: exclude_subpages_from_nav
// Type: Checkbox
// Functionality: If a page has this checked, all of that pages children (sub-pages) will be excluded from the nav menu (but the page itself will be included).
//
// 3) Handle: disable_link_in_nav
// Type: Checkbox
// Functionality: If a page has this checked, it will appear in the nav menu but will not be "clickable" (will not link to any page).
//


Save the file.

After adding the autonav block, click on it, choose Custom Template, and choose header_nav from the dropdown.

You can repeat these steps for each of the different navigation items you want, just make sure to change: the name of the file you create to something easily recognized and the 'top_nav_item' to whatever attribute handle you are looking for.

else if (($current_level > $excluded_parent_level) || !$_c->getAttribute('top_nav_item') || ($current_level > $exclude_children_below_level))
leinteractive replied on at Permalink Reply
leinteractive
The only problem with that approach is that the automav has to load EVERY page in the sitemap before it does the filtering by the attribute.

The benefit of exclude_from_nav is that C5 filters that at the controller level so the pages don't need to be filtered again at the view level. This was one of the big fixes to 5.6 in site speed with C5.