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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How to order "HasManyComplexTableField" elements


Go to End


3 Posts   1367 Views

Avatar
digibrains

Community Member, 130 Posts

15 July 2010 at 10:35am

Edited: 15/07/2010 10:40am

I'm trying to build a slideshow that allows it's images to be managed from the CMS instead of some other non-CMS way.

Using this tutorial on how to create a "quotes" object:
http://doc.silverstripe.org/recipes:example_of_quotes_on_a_page

and this tutorial on object relationships:
http://doc.silverstripe.org/tutorial:5-dataobject-relationship-management

I've been able to create a very nice slideshow class that uses a ComplexTableField to retrieve a list of images.

However, I don't understand how to order my images other than the default order of creation. For each image in my ComplexTableField I've included a field in the cms to enter a number. The plan here is to use that number as a weight to order the list. I'm looking for something like "Order by $SlideOrder ASC" or whatever the equivalent might be. ($SlideOrder is the name of the field I want to order by.)

E.g. Now my table looks like this and it displays in this order:

$Image - $SlideOrder
ImageA.jpg - 3
ImageB.jpg - 1
ImageC.jpg - 2

So they display 3, 1, 2. I'm trying to get them to display 1, 2, 3.

Thanks!
Chris.b

Avatar
Willr

Forum Moderator, 5523 Posts

15 July 2010 at 11:19am

For adding sorting / ordering then you want to check out the DataObjectManager (DOM) module which adds this functionality and a bunch of other stuff. http://silverstripe.org/dataobjectmanager-module/

Avatar
digibrains

Community Member, 130 Posts

15 July 2010 at 1:23pm

I do believe, that's what I'm looking for.

Thanks!

C.b