diff --git a/filesystem/Folder.php b/filesystem/Folder.php index a7fac87f0..4303b4f1f 100644 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -416,14 +416,31 @@ class Folder extends File { $config->addComponent(new GridFieldAction_Edit()); $config->addComponent($gridFieldForm = new GridFieldPopupForms(Controller::curr(), 'EditForm')); $gridFieldForm->setTemplate('CMSGridFieldPopupForms'); - $files = DataList::create('File')->filter('ParentID', $this->ID)->exclude('ClassName', 'Folder'); + + if($this->ID) { + // When a specific folder is selected, show only children files, + // and include children folders to allow navigating into them. + $files = DataList::create('File') + ->filter('ParentID', $this->ID) + ->sort('(CASE WHEN "ClassName" = \'Folder\' THEN 0 ELSE 1 END)'); + } else { + // On the root folder, show all files but exclude folders - newest first. + $files = DataList::create('File') + ->exclude('ClassName', 'Folder') + ->sort('Created', 'Desc'); + } + $gridField = new GridField('File','Files', $files, $config); $gridField->setDisplayFields(array( 'StripThumbnail' => '', - 'Parent.FileName' => 'Folder', + // 'Parent.FileName' => 'Folder', 'Title'=>'Title', + 'Date'=>'Created', 'Size'=>'Size', )); + $gridField->setFieldFormatting(array( + 'Date' => 'Nice' + )); $titleField = ($this->ID && $this->ID != "root") ? new TextField("Title", _t('Folder.TITLE')) : new HiddenField("Title"); @@ -432,23 +449,33 @@ class Folder extends File { new TabSet('Root', new Tab('listview', _t('AssetAdmin.ListView', 'List View'), $titleField, + new LiteralField( + 'UploadButton', + sprintf( + '