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

Migrating from Has-many File Manager to DataObject Manager


Go to End


5 Posts   2493 Views

Avatar
Mans

Community Member, 21 Posts

3 June 2010 at 8:15pm

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 my company site 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

Forum Moderator, 4102 Posts

4 June 2010 at 1:45am

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

Community Member, 21 Posts

4 June 2010 at 2:08am

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

Forum Moderator, 4102 Posts

4 June 2010 at 2:48am

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
bummzack

Community Member, 904 Posts

7 December 2010 at 11:09pm

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.