Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » many_many sort order per relationship

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

Page: 1
Go to End
Author Topic: 1623 Views
  • dynamite
    Avatar
    Community Member
    66 Posts

    many_many sort order per relationship Link to this post

    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

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: many_many sort order per relationship Link to this post

    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.

    1623 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.