Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to pass parameters to $Breadcrumbs?


Go to End


4 Posts   4664 Views

Avatar
juergr

Community Member, 17 Posts

20 December 2011 at 9:15am

I want to display Hidden pages in the Breadcrumbs and I tried different things, but nothing seems to work.

Basicaly this is my BreadCrumbs.ss:

<div id="Breadcrumbs" class="grid_9 alpha">
    <p>$Breadcrumbs</p>
</div>

And I include it in the Page.ss like this:

<% if Level(2) %>
    <% include BreadCrumbs %>
<% end_if %>

At first i was trying to simply pass the parameters like this, bit this is not working, the breadcrumbs stay the same

$Breadcrumbs(20, false, false, true)

then I tried this: (as described here: http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#site-navigation-breadcrumbs

<div id="Breadcrumbs" class="grid_9 alpha">
    <p><% control Breadcrumbs(20, false, false, true) %></p>
</div>

But then I get a error, of course, there is a missing end_control! But if I add this missing piece, the breadcrumbs dissapear.

So, can anyone help me please? What am I doing wrong?

Avatar
Willr

Forum Moderator, 5523 Posts

20 December 2011 at 3:51pm

Try setting that configuration in your Page class.

public function Breadcrumbs() {
return parent::Breadcrumbs(20, false, false, true);
}

Then you can simply use $Breadcrumbs in your template. I think the issue would be around passing so many arguments to SSViewer.

Avatar
juergr

Community Member, 17 Posts

21 December 2011 at 2:13am

Ok, this way it works like a charm.

So multiple parameters are not supported by the SSViewer?

Avatar
Spambanjo

Community Member, 24 Posts

2 December 2014 at 5:47am

Sorry to bump an old thread, but I just found this solution and was left scratching my head as to why I was getting a PHP error message, even though the code actually worked as intended.

It's important to note that this code should go in the Page_Controller, not in the main Page class if you have 'Show Errors' enabled in PHP.

public function Breadcrumbs() {
return parent::Breadcrumbs(20, false, false, true);
}