6

I try to filter a node by the criteria of NID. Naturally I can filter by a single NID, but in this case I need to to filter by multiple NIDs.

I tried to wrote the following number values and non worked:

1, 20, 31

1+20+31

How should I write the number values so that it would work?

Thanks.

1 Answer 1

16

You will need to add contextual filters in the view.

  • Just go to advanced -> contextual filter -> add new 'content:nid' field.
  • Check 'profile default value' option from list entitled 'WHEN THE FILTER VALUE IS NOT AVAILABLE' -> Choose 'Fixed value' option and add multiple nids seperating them via '+' e.g. 1+2+3
  • Then from 'more' fieldset check on 'allow multiple values' option.

This should do it. You can check also in sql query generated by view below it which should show something like this in where clause e.g. WHERE (( (node.nid IN('1', '2', '3') ) )

3
  • 2
    Ah! This was getting really annoying! Didnt see the hidden "multiple" option. Thanks!
    – Collins
    Commented Feb 10, 2015 at 13:45
  • Did you use Seven as your admin theme at the time @Collins ? I love this theme very much for admin but I think it has some small css probs regarding to this (and maybe some other dialogues) in Views... I hope In Drupal 8 these problems will be no longer; Given that Drupal 8 went through a Mobile-first responsivness process, I'm optimistic :)
    – user16289
    Commented Jan 14, 2016 at 8:21
  • Works great until you go past the maxlength of 128 characters - which is all the more easy when your NIDs are higher... Commented Apr 3, 2019 at 16:40

Your Answer

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