Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

FileDataObjectManager grid view filename


5 Posts   1351 Views


12 August 2010 at 4:57am (Last edited: 12 August 2010 4:58am), Community Member, 31 Posts


I have got the file data object manager working roughly as I would like it, with the exception of the grid view of my files showing "#5" for example rather than the title of the file? Any ideas why?


class Publication extends DataObject {
   static $db = array(
      'IssueNumber' => 'Varchar(25)',
      'Date' => 'Date'
   static $has_one = array(
      'Document' => 'File',
      'PublicationPage' => 'PublicationPage'

   function getCMSFields_forPopup() {
      $datefield = new DateField('Date');
      $datefield->setConfig('showcalendar', true);
      $datefield->setConfig('showdropdown', true);
      $datefield->setConfig('dateformat', 'dd/MM/YYYY');
      return new FieldSet(
         new TextField('IssueNumber'),
         new FileIFrameField('Document')


class PublicationPage extends Page {
   static $has_many = array(
      'Publications' => 'Publication'
   static $has_one = array (
      'RootFolder' => 'Folder'
   function onBeforeWrite() {
      if($this->ID) {
         $this->RootFolder()->Title = $this->Title;
   function onAfterWrite() {
      if($this->ID) {
   function onBeforeDelete() {
   function checkFolder() {
      if(!$this->RootFolderID) {
         $folder = Folder::findOrMake("PublicationPage-" . $this->ID);
         $folder->Title = $this->Title;
         $this->RootFolderID = $folder->ID;
      } else {
         $this->RootFolder()->Title = $this->Title;
   function getCMSFields() {
      $fields = parent::getCMSFields();
      $manager = new FileDataObjectManager(
            'IssueNumber' => 'IssueNumber',
            'Date' => 'Date'),
      $manager->setUploadFolder("PublicationPage-" . $this->ID);
      $manager->setAllowedFileTypes(array ('pdf','doc'));
      $fields->addFieldToTab("Root.Content.Publications", $manager);
      return $fields;

class PublicationPage_Controller extends Page_Controller {
   public function init() {


12 August 2010 at 5:11am 4085 Posts



12 August 2010 at 7:03am Community Member, 31 Posts

Thanks for the quick reply!

That worked perfectly for getting the IssueNumber. Now I have decided to use the filename, how would I go about that?

I have tried:


And I had tried creating a method in Publication and calling that, but all to no avail!!


12 August 2010 at 8:36am 4085 Posts

It should fall back on the Title field of your File object if there's not grid label defined. Are the numbers you're getting representative of the DataObject ID, or the File ID? Is the Title field of the File stored in the database?


12 August 2010 at 9:08am (Last edited: 12 August 2010 9:25am), Community Member, 31 Posts

It is the DataObjectID...

EDIT: Don't worry! I was using some old versions of SS and DOM. Thanks very much!