I have a view with a few different displays, each of them with slightly overridden filters, like this one used in a panel.

How do you add this pseudocode via the UI?

AND (node.type='story' OR node.comment_count >=1)

I found an article (Better WHERE's for your Drupal forums with hook_views_query_alter), but I still don't know what to do.

What does the following code do, and what is "advf_filter"?

if ($view->name == 'YOURVIEW') {
  $view->query->add_where('advf_filter',"(node.type='%s' OR node_comment_statistics.comment_count >= %d)",'forum',1);

2 Answers 2


In Drupal 7 (Views 3), it's pretty simple, for regular filters at least:

  • For regular Filters, open the 'rearrange' (or "and/or, rearrange") window by clicking on the arrow next to 'Add'. From here it's simple and self-explanatory - you put your filters into Filter Groups, and can set each filter group to be 'OR' or 'AND'.
  • For Contextual Filters, it's a little bit stranger and is currently undergoing development work. Keep an eye on this issue: Document that contextual filters are included in the first 'and/or' filter group . As the title of that link suggests, all your contextual filters are treated as being part of whatever your first Filter Group is, so make sure there is at least one, and edit that as above.

There's talk in that issue of changing this to something more flexible (watch above link), but that'll take time.

(note - talking about contextual filters is relevant to this question because someone closed a question about setting 'OR' on contextual filters as a duplicate and pointed it to this one)


That issue closed with just a documentation change, here's a couple of relevant ongoing issues to follow...


Even though it's a dev version, I have never had problems with the Views OR module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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