Score:0

Return two values from views exposed filter - filtered value and a default value

us flag

Is it possible to return two values when user chooses a value from a defined list? The values I wish to return are the value that a user chose AND a default value if it exists.

I have a taxonomy list of values (example: 10%, 20%, 25%, 100%, Any%). This list is exposed to the user as a dropdown filter on form.

I have a content type with an entity reference field referring to these values. Some or all of these values may be referenced in this field.

If the user chooses, for example 10% then the returned results should show products that have 10% set but I also want it to return Any%, if that is referenced in the product. So Any% should be shown alongside the product always, if it is referenced on that product.

Is this possible within views UI or do I need a query alter?

Default view before a choice is made

Product 1 Percent Available
10%
20%
30%
45%
Any%

Example 1: User has chosen 10% from exposed filter:

Product 1 Percent Available
10%
Any%

Example 2: User has chosen Any% from exposed filter:

Product 1 Percent Available
Any%
Score:0
ru flag

You can do this by splitting it up into two filters:

The exposed one, as you described it above. Then add 2nd, non-exposed filter on the same field, and the field value must be Any%. Then, in the views UI, create a filter group, move both filters in there, and set the group condition to OR.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.