From a6f8b83e1aff2a121838edb8029602e43f22fe20 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Tue, 14 Aug 2012 11:45:16 +1200 Subject: [PATCH] ENHANCEMENT: Show number of documents on a page in dropdown --- code/DMSSiteTreeExtension.php | 4 ++++ code/cms/DMSDocumentAddExistingField.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/code/DMSSiteTreeExtension.php b/code/DMSSiteTreeExtension.php index 439fd0e..da015a7 100644 --- a/code/DMSSiteTreeExtension.php +++ b/code/DMSSiteTreeExtension.php @@ -76,4 +76,8 @@ class DMSSiteTreeExtension extends DataExtension { } } + + function getTitleWithNumberOfDocuments() { + return $this->owner->Title . ' (' . $this->owner->Documents()->Count() . ')'; + } } \ No newline at end of file diff --git a/code/cms/DMSDocumentAddExistingField.php b/code/cms/DMSDocumentAddExistingField.php index 4146431..fd60a1f 100644 --- a/code/cms/DMSDocumentAddExistingField.php +++ b/code/cms/DMSDocumentAddExistingField.php @@ -4,8 +4,8 @@ class DMSDocumentAddExistingField extends CompositeField { function __construct($name, $title = null) { $this->name = $name; $this->title = ($title === null) ? $name : $title; - - parent::__construct(new TreeDropdownField('PageSelector', 'Add from another page', 'SiteTree')); + + parent::__construct(new TreeDropdownField('PageSelector', 'Add from another page', 'SiteTree', 'ID', 'TitleWithNumberOfDocuments')); } /**