Skip to content

Commit

Permalink
MERGE List view breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
chillu committed Apr 18, 2012
1 parent ca853d7 commit e5000dd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions code/controllers/CMSPagesController.php
Expand Up @@ -26,4 +26,36 @@ public function currentPageID() {
public function isCurrentPage(DataObject $record) {
return false;
}

public function Breadcrumbs($unlinked = false) {
$items = parent::Breadcrumbs($unlinked);

//special case for building the breadcrumbs when calling the listchildren Pages ListView action
if($parentID = $this->request->getVar('ParentID')) {
$page = DataObject::get_by_id('SiteTree', $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->request->getVar('view'),
'q' => $this->request->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 $items;

}
}

0 comments on commit e5000dd

Please sign in to comment.