beforeExtending('updateBreadcrumbs', function (ArrayList $items) { //special case for building the breadcrumbs when calling the listchildren Pages ListView action if ($parentID = $this->getRequest()->getVar('ParentID')) { $page = SiteTree::get()->byID($parentID); //build a reversed list of the parent tree $pages = array(); while ($page) { array_unshift($pages, $page); //add to start of array so that array is in reverse order $page = $page->Parent; } //turns the title and link of the breadcrumbs into template-friendly variables $params = array_filter(array( 'view' => $this->getRequest()->getVar('view'), 'q' => $this->getRequest()->getVar('q') )); foreach ($pages as $page) { $params['ParentID'] = $page->ID; $item = new stdClass(); $item->Title = $page->Title; $item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params)); $items->push(new ArrayData($item)); } } }); return parent::Breadcrumbs($unlinked); } }