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.

General Questions /

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

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

How to order "HasManyComplexTableField" elements


Reply


3 Posts   1121 Views

Avatar
prawnstar

Community Member, 120 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:
[url]http://doc.silverstripe.org/recipes:example_of_quotes_on_a_page[/url]

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

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, 5513 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
prawnstar

Community Member, 120 Posts

15 July 2010 at 1:23pm

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

Thanks!

C.b