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

Preview: DataObjectManager module


Reply


379 Posts   61907 Views

Avatar
Andre

Community Member, 126 Posts

8 May 2009 at 1:18am

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?

Avatar
UncleCheese

4085 Posts

8 May 2009 at 2:07am

@martimiz - I'm not exactly sure what you're looking for. Just a fancier ImageField? SWFUploadIFrameField should give you what you need. I'm using it on several of my projects.

@Andre - You can absolutely have multiple files linked to a DataObject, but you can't use a FileDataObjectManager for that. You have to use a straight DataObjectManager, which you're doing, but you're just cramming a bunch of extra arguments in there, so it's probably just erroring out.

Avatar
Andre

Community Member, 126 Posts

8 May 2009 at 2:16am

I am sorry, I was so stupid, just take DataObjectManager instead of ImagaDataObjectManager.

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
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;
}
}

Avatar
vstrazz

Community Member, 63 Posts

8 May 2009 at 2:34am

Hey guys. I'm having a conflict with complex table field pop-up's in the security section of the CMS when Dataobject_manager is installed. Has anyone else had this issue yet?

Instead of the pop up the edit form is returned consuming the entire browser page.

Avatar
UncleCheese

4085 Posts

8 May 2009 at 2:38am

So to replicate this, I just click the Security tab on any site that has DOM installed? 2.3.1? Browser? I'll try it out. Surprised this hasn't been reported yet.

Avatar
vstrazz

Community Member, 63 Posts

8 May 2009 at 2:50am

Edited: 08/05/2009 2:52am

Just click the security tab, then click edit on one of the groups.

I have a ton of other modules and custom work done, but the dataobject_manager folder is default download. I simply moved the dataobject_manager folder out of my root and retried the issue and it was fine.

NINJA EDIT:// 2.3.1 / Most recent Firefox on XP

Avatar
UncleCheese

4085 Posts

8 May 2009 at 2:52am

I can't replicate it in Safari or Firefox. Anyone else?

Avatar
martimiz

Forum Moderator, 1097 Posts

8 May 2009 at 2:56am

Edited: 08/05/2009 3:03am

@UncleCheese
I tried the SWFUploadIFrameField, but having some issues with it (maybe you could point me in the right direction):

- attach button greys out when you happen to click it before choosing a file
- treedropdown for existing files hangs om 'loading...'

(mozilla 3 win)

So I was thinking: why not have a field that has just a button that uses the popup from the ImageDataObjectManager to add/edit an image, and then maybe shows a thumbnail next to the button. It would keep the cms tabs nice and clean, and still use all extra's from your popup that I like so much, like title, alt and description - much more then the SWFUploadIFrameField does.

This would work nicely on pages that hold several images - think a book cover, an author photo, a company logo, that would be added separately, and not just as a series of images. Could it be done?

@vstrazz
I have the same configuration (2.3.1, XP Mozz 3.0.1) and it works fine for me...
[edit] I have the latest from the svn (142)