I've got content-type includes 'field1', field2' and 'field3'. These fields are integer value. Thanks to Views module I created page 'Page1' with contents. In main menu I've got search whit some filters. After filling filters and entering, we can see appropriate contents in 'Page1'. I'd like to create filters or fields in search to allow user to fill in 'min' and 'max' values. After it I want to choose a content only if 'field1' or 'field2' or 'field3' of that content is beetwen 'min' and 'max'. How can I do it?


1 Answer 1


In Views where it says Filter criteria there is a button that says Add, if you click on the arrow to the right you can access "And/Or, Rearrange", click that.

enter image description here

You now have an UI where you can group filters together and use OR between groups of filters.

In the example below the node should be Published or of type flickr_image. First thing you need to do is click Create new filter group. From there you can drag your filters into your groups. Next select if the operator between the filters should be AND or OR.

Views filter or example

After this add your three fields. Use the filter between, if the filter is exposed it will look like this.

enter image description here

I would keep the first filter exposed and the other not exposed. But then comes the tricky part. The other two filters must inherit the value from the first exposed filter.

I think you need a little bit of glue code to get this going. Put the code below in a custom module. You need to change MYMODULE to the name of your module, MYVIEW to the machine name of your view. And of course field_1 and field_2 to their real names.

function MYMODULE_views_pre_execute(&$view) {   
  if ($view->name == 'MYVIEWNAME') {        
    $filters = $view->display_handler->get_option('filters');   
    $filters['field_2_value']['value']['min'] = $view->exposed_input['field_1_value']['min'];
    $filters['field_2_value']['value']['max'] = $view->exposed_input['field_1_value']['max'];
    $view->display_handler->override_option('filters', $filters);
  • I see it. Thanks Pontus. But what should I do to have got only two inputs (min and max) in search and reach what I described above?
    – user19455
    Jul 31, 2013 at 13:36
  • Yes, I understand it. But what filters should I add?
    – user19455
    Jul 31, 2013 at 13:42
  • I created first filter. In my search appears two additional inputs (That's right). I don't understand what can I do to create two filters more without adding inputs in search. Help me, please.
    – user19455
    Jul 31, 2013 at 13:50
  • I've updated my answer. Jul 31, 2013 at 14:00
  • Thanks for your answer. Is there another way to do that?
    – user19455
    Jul 31, 2013 at 14:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.