Programmatically Creating Breadcrumb Autonav

Permalink
I am trying to programmatically output a breadcrumb autonav in my theme. The autonav displays, but it isn't showing the breadcrumb trail for some reason. When I create an autonav using the editor and same settings, it works fine, but not when I'm doing it programmatically. Here is the code I'm using:

$autonav = BlockType::getByHandle('autonav');
$autonav->controller->orderBy = 'display_asc';
$autonav->controller->displayUnavailablePages = 0;
$autonav->controller->displayPages = 'top';
$autonav->controller->displaySubPages = 'relevant_breadcrumb';
$autonav->controller->displaySubPageLevels = 'enough';
$autonav->render('templates/breadcrumb');


I've attached a screenshot of the breadcrumb trail it outputs. The correct output should be:

Home / About / About Us


The above is what I get when I create the autonav using the editor, but the programmatic version is really messed up.

Any ideas as to why this is happening? Thank you in advance!

1 Attachment

nickelfault
 
nickelfault replied on at Permalink Best Answer Reply
nickelfault
Ended up taking a different approach. Created a stack using a custom template, and outputted the stack like so:

$stack = Stack::getByName('Breadcrumb');
$stack->display();