7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » How do I get ImageDataObjectManager to work?
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 3503 Views |
-
How do I get ImageDataObjectManager to work?

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
-
Re: How do I get ImageDataObjectManager to work?

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.
-
Re: How do I get ImageDataObjectManager to work?

2 October 2009 at 1:28am
Thanks for the quick reply?
Where can I find these docs? -
Re: How do I get ImageDataObjectManager to work?

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
-
Re: How do I get ImageDataObjectManager to work?

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.
-
Re: How do I get ImageDataObjectManager to work?

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')
);
}
} -
Re: How do I get ImageDataObjectManager to work?

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?
| 3503 Views | ||
| Go to Top | Next > |

