Hi, I didn't find if this has been answered before so sorry it it has.
Is there a way to build DataObjects containing more than one Image or File?
What I want to build is a Project Object containing some Description, a Project Title, a Preview Picture, a normal Picture and a File (flv).
Code for the Project Object looks the following:
class ProjectObject extends DataObject{
static $db = array (
'Description' => 'Text',
'ProjectVideoWidth' => 'Text',
'ProjectVideoHeight' => 'Text',
);
static $has_one = array (
'PreviewProjectPicture' => 'Image',
'ProjectPicture' => 'Image',
'ProjectVideo' => 'File',
'ProjectImagePage' => 'ProjectImagePage'
);
public function getCMSFields_forPopup(){
return new FieldSet(
new TextareaField('Description'),
new ImageField('PreviewProjectPicture'),
new ImageField('ProjectPicture'),
new FileField('ProjectVideo'),
new TextField('ProjektVideoWidth'),
new TextField('ProjektVideoHeight')
);
}
}
This should be alright, but now I have no Idea, how to build the ProjectObjectPage.
class ProjectObjectPage extends Page{
static $has_many = array (
'ProjectObjects' => 'ProjectObject'
);
public function getCMSFields(){
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this, // Controller
'ProjectImages', // Source name
'ProjectImage', // Source class
'PreviewProjectPicture', // File name on DataObject
'ProjectPicture', // File name on DataObject
'ProjectVideo', // File name on DataObject
array(
'Description' => 'Description',
'ProjectVideoWidth' => 'ProjectVideoWidth',
'ProjectVideoHeight' => 'ProjectVideoHeight'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.Projects", $manager);
return $fields;
}
}
I think, this is crap, but how can I add more than on File to DataObjects?