Combining simple module list view filters

edited January 2015 in Modules
Is it possible to combine list view filters so that only the results satisfying both filters are shown (an AND scenario rather than an OR)?

Currently (as far as I can tell), if i have a dropdown containing categories (CAT A, CAT B and CAT C) and another containing types (TYPE 1, TYPE 2, TYPE 3) and I select CAT B/TYPE 3, I will get all results that are either in CAT B or that are of TYPE 3 (even if they are, say, in CAT A).

I would like to have a list of only the elements that match both filter choices (that are of TYPE 3 AND in CAT B).

Thanks!

Comments

  • edited 12:19PM
    There is a "filter_join" model property that can be used. By default it is set to "or". It can be changed to "and". Alternatively, you can use a key/val array to say how to join which fields:
    public $filter_join = array('col1' => 'or', 'col2' => 'and'....);
    This will cover most scenarios. However, in more extreme cases, you can always just overwrite the list_items method to properly apply the filtering.
  • edited 12:19PM
    Got it! Fantastic! Thank you.
Sign In or Register to comment.