0

I try to create something like questionnaire using views exposed filters. I have a content type xxx with fields:

field_1 (with options a,b,c)
field_2 (with options a,b,c)
field_3 (with options a,b,c)

I have 9 nodes, each containing only one option (node_1 has only "a" option from field_1 selected, node_2 has only "b" option from field_1 selected etc... so together 9 nodes)

Task: User chooses from 3 dropdown lists. For example choices are (field_1 - a, field_2 - a, field_3 - c)

I need the result to contain :

node that has field_1 with option "a" checked
node that has field_2 with option "a" checked
node that has field_3 with option "c" checked

Is this possible to acheive using views filters or I need another solution? I would like to use any views solution Thank you.

2 Answers 2

1

This seems to be a bug in the Views module. If you have an OR filter group, Views will incorrectly use INNER JOIN instead of LEFT JOIN in the query.

One solution is to patch Views - more info & patch: https://www.drupal.org/node/1766338

Another solution that is using hook_views_query_alter that changes the join type by modifying the query object: Changing an inner join to a left join in views 3.3?

A third solution (see comment below) is to check the "Reduce duplicates" checkbox for the filters in the OR group.

3
  • yes that is it. At the end of first link, there is a solution to tick - reduce duplicates, which works. Thank you
    – loparr
    Commented Sep 9, 2014 at 20:45
  • Can you summarize this a little please? We prefer answers that can stand on their own (as much as possible), and use links for references (eg, to point to the patch).
    – mpdonadio
    Commented Sep 10, 2014 at 13:24
  • @MPD just did it, I hope it's better now.
    – Peter
    Commented Sep 10, 2014 at 15:31
0

Yep. In your view, set create a filter criteria for each of your fields.

check expose this filter to visitors, allowing them to change it.

Operator should be "is one of"

Edit ------------------------------------------------- I've recreated your issue on my local machine, and am seeing the same issues you are. I have had some success with creating group like this: enter image description here

I'm only using 2 filters, but selecting [any, a] does give me back 1-a, 1-b, 1-c, 2-a. However, if I select ANYTHING for field 1, that seems to kill it. It's seems as though if views gets a match for the first group, it doesn't try the second... I'll keep trying to figure out what's going on here... very strange.

2
  • I can not get it to work, I have created filters for all fields and tried it with AND and also OR operator but none of them gives me the resuls I want. Moreover combining fields like this gives no results at all.
    – loparr
    Commented Sep 9, 2014 at 19:04
  • yes, again with OR or AND filter, with separate filter groups, I get no results.
    – loparr
    Commented Sep 9, 2014 at 19:28

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.