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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

How do I get ImageDataObjectManager to work?


Go to End


14 Posts   7511 Views

Avatar
Roweena

Community Member, 28 Posts

2 October 2009 at 1:24am

I've got FileDataObjectManager set up and working ok but I want to use ImageDataObjectManager. I'm following the instructions at http://doc.silverstripe.org/doku.php?id=modules:dataobjectmanager&s=imagedataobjectmanager but the instructions for ImageDataObjectManager as follows:

"The ImageDataObjectManager takes the same arguments and configuration as a FileDataObjectManager. The only difference is that its only allowed file classes are Image or subclasses thereof"

...don't mean much to me as I'm not a developer.

Can any one help with how to set this up or provide some example code?

Thanks

Avatar
UncleCheese

Forum Moderator, 4102 Posts

2 October 2009 at 1:25am

Did you see the docs for FileDOM? That would be a good place to start. The only difference is that it manages images, not just generic files.

Avatar
Roweena

Community Member, 28 Posts

2 October 2009 at 1:28am

Thanks for the quick reply?
Where can I find these docs?

Avatar
Roweena

Community Member, 28 Posts

2 October 2009 at 1:52am

I'm already looking at that, I've set up the file manager and it's working ok but I just don't know which bits of code I need to change and what I need to replace with to make the ImageDataObjectManager work?

Thanks again :-)

Avatar
UncleCheese

Forum Moderator, 4102 Posts

2 October 2009 at 3:22am

It works exactly the same. Just change "FileDataObjectManager" to "ImageDataObjectManager"

e.g...

new FileDataObjectManager(
$this,
'SomeObjects',
'SomeObject',
'SomeFile',
array('Foo' => 'Foo', 'Bar' => 'Bar')
);

becomes..

new ImageDataObjectManager(
$this,
'SomeObjects',
'SomeObject',
'SomeFile',
array('Foo' => 'Foo', 'Bar' => 'Bar')
);

The only requirement is that "SomeFile" in that example is an Image or Image subclass.

Avatar
Roweena

Community Member, 28 Posts

2 October 2009 at 6:13am

Thanks again for your help, I've changed the bits I think shoudl be chanegd as per yoru instructions but the resources tab is just showing blank in the cms, ie the tab is there but has nothing in it. My code is as follows, I'm sure I'm missing something:

class ResourcePage extends Page
{
static $has_many = array (
'Resources' => 'Resource'
);

public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'Resources', // Source name
'Resource', // Source class
'Attachment', // File name on DataObject
array(
'Name' => 'Name',
'Description' => 'Description',
'Category' => 'Category'
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab("Root.Content.Resources",$manager);
return $f;
}

}

AND

class Resource extends DataObject
{
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category' => "Enum('2009, Transitional-Spaces, Brighton-Bands')"
);

static $has_one = array (
'Attachment' => 'Image',
'ResourcePage' => 'ResourcePage'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextareaField('Description'),
new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}

Avatar
Roweena

Community Member, 28 Posts

3 October 2009 at 9:22pm

Ok, so following on from the above post, I've got FileDataObjectManage to work fine, but when I change the code (to the code pasted in last posted) I get a blank image/resource tab in the cms admin, where I should be seeing the image upload buttons/functions. Any ideas?

Go to Top