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

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


Go to End


5 Posts   1453 Views

Avatar
WebSpilka

Community Member, 89 Posts

28 January 2011 at 4:14am

Edited: 28/01/2011 9:02am

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?
http://www.webspilka.com.ua/temp/foto_.png

Avatar
UncleCheese

Forum Moderator, 4102 Posts

28 January 2011 at 9:46am

You can probably just do

SortableDataObject::set_sort_dir("DESC");

Avatar
WebSpilka

Community Member, 89 Posts

28 January 2011 at 10:38pm


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

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

29 January 2011 at 8:39am

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
WebSpilka

Community Member, 89 Posts

3 February 2011 at 3:35am

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?