Programmatically display autoNav block but ignore the exclude nav attribute

Permalink
Hi All,

I am trying to programmatically output a full page list of all pages in hierarchical order.

My topnav has some pages hidden as i dont want every page in my topnav but I do want to list every page for this feature im developing.

I can see that the variable ignoreExcludeNav is being changed from false to true, but the excluded pages aren't being listed for some reason.

I am wondering if there is a specific way I have to set block class variables?

$nav = \BlockType::getByHandle('autonav');
var_dump($nav->controller->ignoreExcludeNav);
$nav->controller->ignoreExcludeNav = true;
var_dump($nav->controller->ignoreExcludeNav);
$nav->controller->orderBy = 'display_asc';
$nav->controller->displayPages = 'top';
$nav->controller->displaySubPages = 'all';
$nav->controller->displaySubPageLevels = 'custom';
$nav->controller->displaySubPageLevelsNum = 2;
$nav->render('view');

View Replies:
hutman replied on at Permalink Reply
hutman
If you look at the autonav controller you will see that the ingnoreExcludeNav is reset in the getNavItems function based on the value that's passed into that function from the view. So in order to do this you'd have to create a new custom template with this adjustment
$navItems = $controller->getNavItems();
change to 
$navItems = $controller->getNavItems(true);

and then set that custom template on your block call
$nav->setTemplate("your_custom_template.php");