7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » FileDataObjectManager grid view filename
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1104 Views |
-
FileDataObjectManager grid view filename

12 August 2010 at 4:57am Last edited: 12 August 2010 4:58am
Hi,
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?
Publication
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'),
$datefield,
new FileIFrameField('Document')
);
}
}PublicationPage
class PublicationPage extends Page {
static $has_many = array(
'Publications' => 'Publication'
);
static $has_one = array (
'RootFolder' => 'Folder'
);
function onBeforeWrite() {
parent::onBeforeWrite();
if($this->ID) {
$this->RootFolder()->Title = $this->Title;
}
}
function onAfterWrite() {
if($this->ID) {
$this->checkFolder();
}
parent::onAfterWrite();
}
function onBeforeDelete() {
parent::onBeforeDelete();
$this->RootFolder()->delete();
}
function checkFolder() {
if(!$this->RootFolderID) {
$folder = Folder::findOrMake("PublicationPage-" . $this->ID);
$folder->Title = $this->Title;
$folder->write();
$this->RootFolderID = $folder->ID;
$this->write();
} else {
$this->RootFolder()->Title = $this->Title;
$this->RootFolder()->write();
}
}
function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this,
'Publications',
'Publication',
'Document',
array(
'IssueNumber' => 'IssueNumber',
'Date' => 'Date'),
'getCMSFields_forPopup'
);
$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() {
parent::init();
}
} -
Re: FileDataObjectManager grid view filename

12 August 2010 at 5:11am
$manager->setGridLabelField('IssueNumber');
-
Re: FileDataObjectManager grid view filename

12 August 2010 at 7:03am
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:
'Document.Title'
'Document()->Title'And I had tried creating a method in Publication and calling that, but all to no avail!!
-
Re: FileDataObjectManager grid view filename

12 August 2010 at 8:36am
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?
-
Re: FileDataObjectManager grid view filename

12 August 2010 at 9:08am Last edited: 12 August 2010 9:25am
It is the DataObjectID...
EDIT: Don't worry! I was using some old versions of SS and DOM. Thanks very much!
| 1104 Views | ||
|
Page:
1
|
Go to Top |

