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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

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

Question about the breadcrumbs public function

Go to End

8 Posts   4281 Views


Community Member, 167 Posts

3 February 2008 at 5:10pm

Using $Breadcrumbs in a template will generate a trail of links with the page title as link name. I think it would be better to have the navigation label as link name (after all, it is navigation, and in my case some pages have rather long page titles). If I understand it correctly, the breadcrumbs get generated by a public function in SiteTree.php:

public function Breadcrumbs($maxDepth = 20, $unlinked = false,
$stopAtPageType = false) {
$page = $this;
$parts = array();
$i = 0;
while(($page && (sizeof($parts) < $maxDepth)) ||
($stopAtPageType && $page->ClassName != $stopAtPageType)) {
if($page->ShowInMenus || ($page->ID == $this->ID)) {
if($page->URLSegment == 'home') {
$hasHome = true;
$parts[] = (($page->ID == $this->ID) || $unlinked)
? Convert::raw2xml($page->Title)
: ("<a href=\"" . $page->Link() . "\">" . Convert::raw2xml($page->Title) . "</a>");
$page = $page->Parent;

return implode(" &raquo; ", array_reverse($parts));

So, if I replace 'Title' with 'MenuTitle' it would do what I want, right? Can I safely do this, or are there other functions in the CMS that depend on the fact that the breadcrumb function uses 'Title'?

Thanks in advance!


Community Member, 167 Posts

4 February 2008 at 1:35pm

Hmm. Anyone?


Community Member, 105 Posts

4 February 2008 at 1:47pm

My answer is to test and see, and if it goes *kaboom*, try to undo what you did, and if that doesn't help, just re-install :)


Community Member, 167 Posts

4 February 2008 at 4:55pm

Well, yeah, you're right of course, and this is certainly doable on a test server, no problem. But even if things seem to be OK, there can always be that little catch and those things are sometimes easily answered by one of the core devs, so I just tried to get a little response ;)

More so actually, because I really wondered why one would want page titles in a breadcrumb trail and not navigation labels...


Community Member, 2 Posts

10 December 2008 at 9:56am

SilverRay, I'm in 100% agreement with you on this one. The page titles make no sense in the breadcrumbs, after all bread crumbs are NAVIGATION items. Did you ever find a solid solution to this? I'm pretty new to SilverStripe, not really into modifying core files yet, but I for sure want the navigation label instead of the page titles in my breadcrumbs.


Community Member, 2 Posts

11 December 2008 at 6:11am

Modifying the SiteTree.php file as you outlined above seems to have done the trick. I'm a little hesitant to publish modified core code, but its certainly working beautifully on my development site.

Thanks for starting this thread, and posting that solution!


Community Member, 470 Posts

11 December 2008 at 8:29am

I would agree that having the menu title is a better option. I've never understood why it was setup the way it was.


Forum Moderator, 5523 Posts

12 December 2008 at 5:23pm

Make this a ticket + patch and one of the core devs can merge this in. Fully agree with the Nav label thing, as long as it defaults to page title if nav label doesn't exist for some reason.

I would think you can do this pretty safely, doubt it will break too much which relies on that. Maybe you would even want to pass a parameter to the Breadcrumbs function with what field name to use - defaulting to MenuTitle. So then you could if so some reason you had a custom field you could display that instead / Title if you want