Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Listing Many_Many objects - but with filters

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

Page: 1
Go to End
Author Topic: 404 Views
  • Futureweb
    Community Member
    232 Posts

    Listing Many_Many objects - but with filters Link to this post

    Hi, I have a many_many relationship all working

    in my template I can do this

    <% control group %>
    <% control people %>
    <% end_control %>
    <% end_control %>

    this lists the group, and the people that have many_many relations to the group. simple

    however, I need to filter both the group dataobject and the people dataobject.
    the group just needs to be lists by sorted by Title, but the people need a search filter and sort.

    I can create a function 'sortGroup' and use in place of just using 'group' in the template

    public function sortGroup() {
       return DataObject::get('Group', '', '`Title` ASC');

    but i'm not sure how I would then create my filtered, sorted dataobject search to find all the many_many records within each group.
    any ideas much appreciated.

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.