From 804e2daa71b180c216feeb7516e84adb390b2b32 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 28 Feb 2012 18:48:33 +0100 Subject: [PATCH] ENHANCEMENT Breadcrumbs support in GridFieldPopupForms (CMS only) --- forms/gridfield/GridFieldPopupForms.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/forms/gridfield/GridFieldPopupForms.php b/forms/gridfield/GridFieldPopupForms.php index 10eaaf0fd..1caac1049 100755 --- a/forms/gridfield/GridFieldPopupForms.php +++ b/forms/gridfield/GridFieldPopupForms.php @@ -291,4 +291,29 @@ class GridFieldPopupForm_ItemRequest extends RequestHandler { function getTemplate() { return $this->template; } + + /** + * CMS-specific functionality: Passes through navigation breadcrumbs + * to the template, and includes the currently edited record (if any). + * see {@link LeftAndMain->Breadcrumbs()} for details. + * + * @param boolean $unlinked + * @return ArrayData + */ + function Breadcrumbs($unlinked = false) { + if(!($this->popupController instanceof LeftAndMain)) return false; + + $items = $this->popupController->Breadcrumbs($unlinked); + if($this->record) { + $items->push(new ArrayData(array( + 'Title' => $this->record->Title, + 'Link' => false + ))); + } + + // TODO Remove once ViewableData->First()/Last() is fixed + foreach($items as $i => $item) $item->iteratorProperties($i, $items->Count()); + + return $items; + } } \ No newline at end of file