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:

Customising the CMS /

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

Extendable breadcrumbs

Go to End

2 Posts   2731 Views


Community Member, 11 Posts

23 July 2010 at 10:59pm

I've been busy with a couple of pages that use the DOM-module. Everything works great, I have a page with an overview, and a page with each individual data object.

What I still miss is the opportunity to add my data-object-page to the breadcrumbs. Let's say I have a ResourcePage which shows all Resource objects. When you click on a Resource object, you go to it's individual page. At that point you are still using the ResourcePage code to retrieve the Resource object. Therefor the breadcrumbs show you are on the ResoursePage, not on the page of the Resource.

At this moment there is no easy way to add an extra part to the breadcrumbs which would indicate that we visit an individual Resource. There's no Breadcrumb class that can be used to easily build custom breadcrumbs. Does anyone know how to accomplish this? Would this be something to build into Silverstripe at a point?



Community Member, 288 Posts

25 July 2010 at 7:37am

Edited: 25/07/2010 7:41am

In short, you can always override the Breadcrumbs function in Sitetree. I always do and make it return a DataObjectSet instead of pre formatted html. It looks like this.

public function Breadcrumbs($maxDepth = 20, $unlinked = false, $stopAtPageType = false, $showHidden = true) {
	$page = $this;
	$parts = array();
	$i = 0;
		&& (!$maxDepth || sizeof($parts) < $maxDepth)
		&& (!$stopAtPageType || $page->ClassName != $stopAtPageType)
	) {
		if($showHidden || $page->ShowInMenus || ($page->ID == $this->ID)) {
			if($page->URLSegment == 'home') $hasHome = true;
			$parts[] = $page;
		$page = $page->Parent;
	if ($this->ClassName != "HomePage") {
		$parts[] = DataObject::get_one("HomePage");
	$parts = array_reverse($parts);
	$bdoSet = new DataObjectSet();
	foreach ($parts as $breadcrumb) {
	return $bdoSet;

It's got some custom behaviour for my HomePage class that you probably want to strip out but you should be able to do what you want with that as your base.