Breadcrumb template block

Hi, I am trying to insert into my template a breadcrumb template block but I am not able to get the right breadcrumb.

The structure of the website is like:

-- level 1
-- section
--- article

The code I am using is:

$autonav = BlockType::getByHandle('autonav');
$autonav->controller->orderBy = 'display_asc';
$autonav->controller->displayPages = 'top'; 
$autonav->controller->displaySubPages = 'relevant_breadcrumb'; 

I added it into my custom theme `elements/header.php`

But in in the article page I only got:

Home > level 1

instead of:

Home > level 1 > section > article

I was not able to find the error.
Thanks for your help,

View Replies: View Best Answer
CC3381 replied on at Permalink Reply
benfrainuk replied on at Permalink Reply
Well, pay attention to Jordan's info before mine (he's a C5 Ninja) but here is the code I used which works like you want it:

<?php $breadcrumbs = BlockType::getByHandle('autonav');
                           $breadcrumbs->controller->displayPages = 'first_level';
                           $breadcrumbs->controller->orderBy = 'display_asc';                    
                           $breadcrumbs->controller->displaySubPages = 'relevant_breadcrumb';  
                           $breadcrumbs->controller->displaySubPageLevels = 'all';
carusog replied on at Permalink Best Answer Reply
Ok, first of all, thank you both.
The reference article (btw, great C5 resource!) was great and very clear about options.

The code snippet made me notice I forgot to add the `breadcrumbs->controller->displaySubPageLevels` variable. Once added, it worked perfectly.

You should change your `displayPages` variable from

$breadcrumbs->controller->displayPages = 'first_level';


$breadcrumbs->controller->displayPages = 'top';

since `first_level` is not a valid variable.

It works anyway since default is `top`. Try to remove it and it works as well.
I prefer to keep it ("explicit is better then implicit").

The full working code is:

    $breadcrumbs = BlockType::getByHandle('autonav');
    $breadcrumb->controller->orderBy = 'display_asc';
    $breadcrumb->controller->displayPages = 'top'; 
    $breadcrumb->controller->displaySubPages = 'relevant_breadcrumb'; 
    $breadcrumb->controller->displaySubPageLevels = 'all';
carusog replied on at Permalink Reply
Do you know how to exclude pages with "exclude_nav" attribute checked?
I am now able to get rid of them. :(
webporter replied on at Permalink Reply
Months late, I know... but I just wanted to add that I put the breadcrumb trail into my template by creating Global Stack called "Breadcrumb" that simply contains my autonav block with the breadcrumbs custom template applied.

All I add to my template is this code:

$bc = new GlobalArea('Breadcrumbs');

Everything else is created/configured within the c5 user interface.

This puts breadcrumbs on all pages of my site.

Works well for me :)