I’m working on an interface to allow students to filter scholarships and fellowships by things like their Class Year, the related Discipline, the Region the fellowship applies to, etc. I’m trying to make this with a Views + Better Exposed Filters on a Drupal 8 site.
I’ve had a request by the person entering the content that, if they leave the field blank went entering the content, that should mean it applies to any and all values for that field.
So a student selecting “Freshman” in Class Year should still see results where either that fellowship has been explicitly marked as Freshman (or Freshman and Sophomores or whatever) or also where the content admin selected no value at all for Class Year.
I’m still new to making views, so I tried several things, none of which seemed to work.
- I initially thought this was what the Grouped filters (seen after checking the filter criteria as exposed) might be for. I still didn’t really understand how it works, but I tried both allowing multiple selections and not, but never saw a useful result.
- I briefly looked into Global: Combine fields filter but despite forcing and adding fields, I could only get it to choose from fields like Text (formatted), not List (text).
I then tried rearranging the filter criteria into groups, something like:
Content: Content type = Fellowships AND
Content: Published = YesAND
Content: Class Year (empty) OR
Content: Class Year (exposed) (set to “Is one of”) AND
Content: Region (empty) OR
Content: Region (exposed) (set to “Is one of”)
None of the variations of this I’ve tried worked. For example, not exposing the “empty” ones makes for no results, setting them to “is none of” instead mostly got me errors, checking “multiple selections allowed” or “required” doesn’t make a difference, etc.
At this point I’m not sure if I’m just not understanding the proper ways to use Views, or have a shaky grasp of logic in general, or perhaps am running into something like this Drupal bug about “Incorrect filter group OR behavior” (though the workarounds like switching the order of filters or checking “reduce duplicates” have given me no luck so far).
While I could go back and tell her, sorry, she’ll have to manually select all the options in those fields, on hundreds of nodes, I’d like to save her the work, and I would also think her approach would be more future-proof when new values for fields like Region and Discipline get added.
Does anybody know what I’m doing wrong?