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

Migrating from Has-many File Manager to DataObject Manager


Reply

5 Posts   1656 Views

Avatar
Mans

3 June 2010 at 8:15pm Community Member, 21 Posts

Hi all,

I'm considering replacing the Has-many File Manager module on my site with the DataObject Manager. Has anyone else done this?

On [url=http://www.typodesign.se/]my company site[/url] I am currently displaying images using this code:

<% if AttachedFiles(MyImages) %>
<div id="imgGallery">
<% control AttachedFiles(MyImages) %>
<% if First %><a href="$URL" title="$Title" rel="lightbox" class="storbild">$SetWidth(370)</a><% end_if %>
<a href="$URL" title="$Title" class="miniatyr">$SetWidth(80)</a>
<% end_control %>
</div>
<% end_if %>

This shows the first image attached to the page as a large preview, and the following images as miniatures beneath it.

How would one accomplish the same thing using the DataObject Manager?

Yours,
Måns

Avatar
UncleCheese

4 June 2010 at 1:45am 4085 Posts

DOM is not a frontend tool -- it's used in the backend to manage your data relationships, so the only difference is that you would have a more robust interface for uploading/managing your file objects in the CMS.

Avatar
Mans

4 June 2010 at 2:08am Community Member, 21 Posts

So the code can stay exactly the same? Excellent!

Is DOM fully compatible with SS 2.4.0? I thought I'd upgrade while I'm at it.

Yours,
Måns

Avatar
UncleCheese

4 June 2010 at 2:48am 4085 Posts

No, totally different code. The big difference between FileDOM and HasManyDOM, from a code standpoint, is that HasManyDOM requires you to decorate your File object for custom fields, while a FileDOM manages DataObjects that contain files, e.g.

MyUploadable extends DataObject
{
static $db = array (
'CustomField' => 'Text',
'AnotherCustomField' => 'Varchar'
etc..
);

static $has_one = array (
'File' = 'File'
);

public function getCMSFields() {
// etc..

}
}

Avatar
banal

7 December 2010 at 11:09pm Community Member, 901 Posts

Sorry for digging out an old thread. I stumbled across this and thought I might add a link to a solution on how to migrate Has-many File Manager to DOM: http://silverstripe.org/all-other-modules/show/14630

Just in case anybody else finds this thread.