Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Migrating from Has-many File Manager to DataObject Manager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1628 Views
  • Mans
    Avatar
    Community Member
    21 Posts

    Migrating from Has-many File Manager to DataObject Manager Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Migrating from Has-many File Manager to DataObject Manager Link to this post

    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.

  • Mans
    Avatar
    Community Member
    21 Posts

    Re: Migrating from Has-many File Manager to DataObject Manager Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Migrating from Has-many File Manager to DataObject Manager Link to this post

    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..

    }
    }

  • banal
    Avatar
    Community Member
    901 Posts

    Re: Migrating from Has-many File Manager to DataObject Manager Link to this post

    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.

    1628 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.