Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Filtering Pages on multiple many-many related DataObjects

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

Page: 1
Go to End
Author Topic: 1102 Views
  • Felicitas
    Avatar
    Community Member
    16 Posts

    Filtering Pages on multiple many-many related DataObjects Link to this post

    Hi,

    I'm having problems with filtering Pages on their many-many related DataObjects.

    I have a CompanyPage. Each CompanyPage has a many-many relation with four DataObjects (Levels, Products, Markets, Competences).

    In the CompanyHolderPage I would like to have a combined filter for these DataObjects, where the user can choose a combination of levels, products, markets and competences and the output will be a list of the corresponding pages for which this is true.

    Does any one have any example code or a hint in the right direction?

    Thanks,

    Felicitas

  • swaiba
    Avatar
    Forum Moderator
    1769 Posts

    Re: Filtering Pages on multiple many-many related DataObjects Link to this post

    This is not the right way - but I've used it as it is quick and easy...

    class MyModelAdmin_CollectionController extends ModelAdmin_CollectionController {
       function getSearchQuery($searchCriteria){
          $query = parent::getSearchQuery($searchCriteria);

          if ($this->modelClass == 'MyModel'){
             $query->where[] = ''; //ADD YOUR SQL HERE, using stuff from $searchCriteria
          }
       }
    }

  • Felicitas
    Avatar
    Community Member
    16 Posts

    Re: Filtering Pages on multiple many-many related DataObjects Link to this post

    Thanks for your reply. Maybe this is the right direction. Right now I have four dropdown boxes, one for each dataobject, but not a combination of them.

    1102 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.