Need help with hardcoded breadcrumbs please!!!

Permalink
I am using the following code in my page template to hardcode breadcrumbs.

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


The resulting breadcrumb is this:
Home > MediaPress Releases

I want it to be this:
MediaPress > Press Releases

As you can see, it's missing the caret symbol between the 2nd and 3rd level. Also, I'd like to get rid of "Home", as I already have a Home link in the main autonav.

This is the code for view.php in autonav/templates/breadcrumb/view.php - What can I add/change to make it work how I want?

<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
$navItems = $controller->getNavItems();
foreach ($navItems as $ni) {
   if (!$ni->isFirst) {
      echo ' <span class="ccm-autonav-breadcrumb-sep">></span> ';
   }
   if ($ni->isCurrent) {
      echo $ni->name;
   } else {
      echo '<a href="' . $ni->url . '" target="' . $ni->target . '">' . $ni->name . '</a>';
   }
}

mehreenbaakza
View Replies: View Best Answer
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
You are displaying pages from the top level (displayPages = 'top'). You will need to set this to display pages from a specified page, which you can get using the page's path (Page::getByPath('/MediaPress');
adajad replied on at Permalink Best Answer Reply
adajad
The missing > (greater than symbol) is a known bug in 5.6 and I have provided a fix in the bug tracker:

http://www.concrete5.org/developers/bugs/5-6-0-2/core-auto-nav-brea...

EDIT:
You could give it a try with:
$bt = BlockType::getByHandle('autonav');
$bt->controller->displayPages = 'top_level';
$bt->controller->orderBy = 'display_asc';
$bt->controller->displaySubPages = 'relevant_breadcrumb'; 
$bt->controller->displaySubPageLevels = 'enough';
$bt->render('templates/breadcrumb');


And try with this in your breadcrumb template:
<?php  defined('C5_EXECUTE') or die(_("Access Denied."));
$navItems = $controller->getNavItems();
$i = 0;
foreach ($navItems as $ni) {
   if ($i>1) {
      echo ' <span class="ccm-autonav-breadcrumb-sep">></span> ';
   }
   if ($ni->isCurrent) {
      echo $ni->name;
   } else if (!$ni->isHome) {
      echo '<a href="' . $ni->url . '" target="' . $ni->target . '">' . $ni->name . '</a>';
   }
   $i++;
}


I don't know if it fits your needs, but a quick test here gives the result I think you are after.
mehreenbaakza replied on at Permalink Reply
mehreenbaakza
Thanks so much NJunky an adajad for your replies....

adajad, your fix was awesome, worked right away, thanks!