Hardcoded autonav that only shows navs with attributes

Permalink
Most navigation on my sites are built in the templates, but I don't know how to use this code to show all links from the site map that have a certain attribute; a checkbox named info_nav

<?php 
$bt = BlockType::getByHandle('autonav');
$bt->controller->displayPages = 'top';
$bt->controller->orderBy = 'display_asc';                    
$bt->controller->displaySubPages = 'relevant_breadcrumb';
$bt->controller->displaySubPageLevels = 'all';
$bt->render('templates/bootstrap_breadcrumbs');
?>


I hoped a controller could be used above, but from searches I came up empty. I assume a custom template will have to be used, but have failed creating one that works. Does anyone have a good starting point or example?

Thanks!

 
hutman replied on at Permalink Reply
hutman
I think you could probably use a PageList for this instead of the Autonav, something like this

$nh = Core::make('helper/navigation');
$th = Loader::helper('text');
Loader::model('page_list');
$pl = new PageList();
$pl->filterByAttribute('info_nav', 1, '=');
$pages = $pl->get(100);
if(count($pages) > 0){
   echo '<ul>';
   foreach($pages as $page){
      $title = $th->entities($page->getCollectionName());
      $url = ($page->getCollectionPointerExternalLink() != '') ? $page->getCollectionPointerExternalLink() : $nh->getLinkToCollection($page);
      $target = ($page->getCollectionPointerExternalLink() != '' && $page->openCollectionPointerExternalLinkInNewWindow()) ? '_blank' : $page->getAttribute('nav_target');
      echo '<li><a href="'.$url.'" target="'.$target.'">'.$title.'</a></li>';
   }
   echo '</ul>