Possible to hide site sections from autonav when within other sections (or create multiple, unique, autonavs)?

Permalink
I am working on a site that consists of a home page and then three sub-sections. Each sub-section has a parent item and many children.

What I am wondering is if there is a way to use the autonav and only show the parent and children of the section a user is in? In other words, each section will have its own navigation and the navigation for the other sections won't display. I can't figure out how this can be accomplished with the autonav.

Currently, I have the autonav hard coded in my template:

<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>


I don't mind creating three different page templates if need be - one for each nav - but I don't know how this would work. The only thing I need is to have the navs be autonavs so new pages will append to the nav when users create them.

Any advice would be much appreciated!

Thanks!

 
adajad replied on at Permalink Best Answer Reply
adajad
Have you tried this?

<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'second_level';
$nav->controller->displaySubPages = 'relevant';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>
hollyb replied on at Permalink Reply
That works pretty well! I tried using this:

<?php
$nav = BlockType::getByHandle('autonav');
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'custom';
$nav->controller->displayPagesCID = '124';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 1;
$nav->render('view');
?>


but it would require a different autonav for each section. Your way, is actually much easier, I think.

Thanks!