diff --git a/code/Report.php b/code/Report.php index dad52df2..3a87e659 100644 --- a/code/Report.php +++ b/code/Report.php @@ -29,6 +29,7 @@ use SilverStripe\ORM\SS_List; use SilverStripe\Security\Member; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; +use SilverStripe\View\ArrayData; use SilverStripe\View\ViewableData; /** @@ -464,10 +465,8 @@ class Report extends ViewableData /** - * Return the name of this report, which - * is used by the templates to render the - * name of the report in the report tree, - * the left hand pane inside ReportAdmin. + * Return the name of this report, which is used by the templates to render the name of the report in the report + * tree, the left hand pane inside ReportAdmin. * * @return string */ @@ -475,4 +474,14 @@ class Report extends ViewableData { return $this->title(); } + + /** + * Return additional breadcrumbs for this report. Useful when this report is a child of another. + * + * @return ArrayData[] + */ + public function getBreadcrumbs() + { + return []; + } } diff --git a/code/ReportAdmin.php b/code/ReportAdmin.php index 8173681e..b18a1d9f 100644 --- a/code/ReportAdmin.php +++ b/code/ReportAdmin.php @@ -172,11 +172,21 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider // Uses session state for current record otherwise. $items[0]->Link = singleton('SilverStripe\\Reports\\ReportAdmin')->Link(); - if ($this->reportObject) { + if ($report = $this->reportObject) { + $breadcrumbs = $report->getBreadcrumbs(); + if (!empty($breadcrumbs)) { + foreach ($breadcrumbs as $crumb) { + $items->push($crumb); + } + } + //build breadcrumb trail to the current report $items->push(new ArrayData(array( - 'Title' => $this->reportObject->title(), - 'Link' => Controller::join_links($this->Link(), '?' . http_build_query(array('q' => $this->request->requestVar('q')))) + 'Title' => $report->title(), + 'Link' => Controller::join_links( + $this->Link(), + '?' . http_build_query(array('q' => $this->request->requestVar('q'))) + ) ))); }