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

ImageDataObjectManager. How to automatically insert the photo in the top of the list?


Reply

5 Posts   1095 Views

Avatar
fiord

28 January 2011 at 4:14am (Last edited: 28 January 2011 9:02am), Community Member, 79 Posts

Hi
I have

class Foto extends DataObject
...


and in my FotoPage

$manager = new ImageDataObjectManager(
         $this, // Controller
         'Fotos', // Source name
         'Foto', // 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.Fotos",$manager);


in my _config.php
I set

SortableDataObject::add_sortable_classes(array('Foto'));


How to rearrange photos? Now when I add a Foto, it ceases at the end of the list. How to make it automatically becomes the first?
[url]http://www.webspilka.com.ua/temp/foto_.png[/url]

Avatar
UncleCheese

28 January 2011 at 9:46am 4085 Posts

You can probably just do

SortableDataObject::set_sort_dir("DESC");

Avatar
fiord

28 January 2011 at 10:38pm Community Member, 79 Posts

Thanks
but SortableDataObject:: set_sort_dir ("DESC");
change the order of a site,
[url]http://www.webspilka.com.ua/temp/foto_1.png[/url]

but the administrative part of it remained as before. How can I change the order for the admin part?

Avatar
UncleCheese

29 January 2011 at 8:39am 4085 Posts

Right. The backend always reflects how the objects will be displayed on the frontend. Otherwise, it would be really confusing!

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
fiord

3 February 2011 at 3:35am Community Member, 79 Posts

Please tell if I have two classes.

class Foto extends DataObject ...
class MiniThumbs extends DataObject

For one (Foto) want to change the sorting site.
For the second (MiniThumbs) to leave as it was.

SortableDataObject::Foto:: set_sort_dir ("DESC");
SortableDataObject::MiniThumbs:: set_sort_dir ("DESC");

It can be done?