Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Drag & Drop on resouce page

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: 886 Views
  • Bambii7
    Avatar
    Community Member
    254 Posts

    Drag & Drop on resouce page Link to this post

    Does anyone have any hints on activating the drag and drop reordering as seen in the AssetManager?
    In the example code of ResourcePage is it possible to activate it in the 'new FileDataObjectManager'. I thought it would be possible with $manager->showAll = true; or $manager->sortable();

    I managed to get it going in a sense by adding
       "SortOrder" => "Int"
    to db array, and
       static $default_sort = "SortOrder";
    in Resource.php

    then
       $manager->showAll = true;
    in ResourcePage.php

    I'm not sure if there's an easier way or if there's anything wrong with the current method...

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drag & Drop on resouce page Link to this post

    You need to add in your _config.php:

    SortableDataObject::add_sortable_class('MyDataObject');

    That will decorate in the field for you and handle the sort controller for that object. This is explained in the documentation.

  • Bambii7
    Avatar
    Community Member
    254 Posts

    Re: Drag & Drop on resouce page Link to this post

    .........I saw that in the documentation, but was hellishly confused at how assetmanager was achieving it without being in the config. Thank you Mr Uncle Cheese, it works a beaut

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drag & Drop on resouce page Link to this post

    The DOM will automatically add file as a sortable class if you have override_asset_admin set to true.

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