0

I have read a dozen of open tickets on this issue, but none of them explains how to solve this. Lets say I have a raw array of nids and wanting to override the query in a hook for the nid filter. The nid filter allows only 1 value or some of the operators given in the image below.

enter image description here

There isnt an operator "is one of" as in the taxonomy reference filter. So how could this be overriden and allow multiple values for the nids? Is this possible perhaps within the hook_views_query_alter()?

6
  • You can add more than one NID filter, and even change the operator between them to OR from AND if needed. You can also use the last option Regular expression? Here is an example: drupal.stackexchange.com/questions/267914/…
    – prkos
    Mar 3 at 17:37
  • You could also use Regular expression with ^[nid1|nid2|nid3]$ replacing nid1 etc with the actual IDs.
    – Jaypan
    Mar 3 at 19:01
  • @Jaypan The regex is a bit buggy, if there is a nid=8, and i put that in the regex, it will also take the nids 88 or 888 in the result. Mar 4 at 18:32
  • Is making a views plugin a good solution? Mar 4 at 18:33
  • Ahh, yeah, I gave it a range rather than a set. Try this: ^(nid1|nid2|nid3)$
    – Jaypan
    Mar 4 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.