Jump to:

3461 Posts in 1065 Topics by 740 members

Data Model Questions

SilverStripe Forums » Data Model Questions » HasManyComplexTable data extraction/manipulation

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

Page: 1
Go to End
Author Topic: 963 Views
  • DigoART
    Community Member
    13 Posts

    HasManyComplexTable data extraction/manipulation Link to this post

    Hi All,

    I ran into interesting problem, which I can't solve in a easy way, so thought someone could help me on that. (Well, I think the solution could be in interest for other members)

    The situation is -
    1. I've got a list of services which are extended from "Page" class and are used as a pages of services description on the website.
    These have Many_many relation to Case studies:

    static $belongs_many_many = array(
    'CaseStudy' => 'CaseStudy'

    2. I've got a Case studies list , which would include several Services out of all of services

    static $many_many = array(
    'Services' => 'Services'

    $tablefield = new ManyManyComplexTableField(
                   'Title' => 'Title'
          $f->addFieldToTab("Root.Content.Services", $tablefield);

    Admin adds services as pages, and then can tick the checkbox for each CaseStudy , to indicate which services where used for the particular case study.

    Now the problem to be solved:

    On the case study page I need outputting ALL of the services , however those that are checked for that case study should have different highlighting color. I thought of approach where I' would select all services in one query, selected service in other query , run a one-by-one comparison, adding extra value, for those that should be highlighted. However , it looks to me that this could be somehow in a more "proper" datamodel approach, so if you have any ideas how to implement that in a proper way - would appreciate your help.

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.