drupaldrupal-viewsdrupal-exposed-filterhook-form-alter

Drupal 7 Views Expose Filter Price Range as Checkboxes


I am using Drupal 7 to build a product reviews site. The product reviews search page is built with Views 3 and Better Exposed Filters. I need an exposed filter for a price field that consists of price ranges as checkboxes. I have set up a grouped exposed filter for price with the proper ranges, made the filter allow multiple selections and then implemented hook_form_alter to set the filter to be themed with BEF checkboxes. The only problem now is the filter's where clause is searching for the ranges with an AND clause instead of an OR. So, I would like the user to select multiple price ranges and the results include products within either price range but instead the search is looking for product that are in both ranges, resulting in no products.

I have attempted to use hook_views_query_alter, but can not output so much as a dsm('test'). I think this may be because the view uses autosubmit.

Does anyone know how I can get this filter to work properly?


Solution

  • As the Advanced documentation of the Filter section says:

    When using grouped filters with the option: 'Enable to allow users to select multiple items' checked, you probably may want to to place the filter in a separated group and define the operator of the group as 'OR'. This may be neccesary because in order to use multiple times the same filter, all options have to be applied using the OR operator, if not, probably you will get nothing listed since usually items in a group are mutually exclusive.

    Therefore, you may want to create a new group (going to the 'reorder tab') and set the operator to OR. Then, just move the exposed filter inside that group.