Permalink
Browse files

ENHANCEMENT Breadcrumbs support in GridFieldPopupForms (CMS only)

  • Loading branch information...
1 parent af9e46a commit 804e2daa71b180c216feeb7516e84adb390b2b32 @chillu chillu committed Feb 28, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 forms/gridfield/GridFieldPopupForms.php
@@ -291,4 +291,29 @@ function setTemplate($template) {
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;
+ }
}

0 comments on commit 804e2da

Please sign in to comment.