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.

Data Model Questions /

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

many_many sort order per relationship


Go to End


2 Posts   2543 Views

Avatar
dynamite

Community Member, 66 Posts

17 September 2009 at 5:18am

Hello,

I have "ArticlePages" and "Authors" and have it working with many_many and belongs_many_many

I would like to customize the sort order on a per relationship basis. That way, on one ArticlePage the first author listed won't necessarily be the first author listed on a different ArticlePage.

In the CMS, I am using ManyManyDataObjectManager from the DataObjectManager module.

Any ideas, hints, etc would be awesome!

Thank you... Jeremy

Avatar
Ingo

Forum Moderator, 801 Posts

27 September 2009 at 4:26pm

From a datamodel perspective, have a look at DataObject::$many_many_extraFields, which can be used to implement a sorting column. You can add this information through ComponentSet->add(), although there's no way in the ORM to read them out, apart from using raw SQL. Not sure about the interface, and wether DataObjectManager supports this extradata. Should be fairly easy to implement though.