0

I have a set of taxonomies that are related to a role- each member of the role gets their own set of values, plus a default value that is common to everyone. For example:

uid | tid | taxname
20 | 200 | name1
20 | 201 | name2
20 | 202 | name3
21 | 203 | name4
22 | 204 | name5
0  | 205 | default
So users 21 & 22 each have 1 term plus the default term, user 20 has 3 terms plus the default term.

I am trying to figure out how to setup an entity reference View that would display the terms available to each user. I know how to setup the entity reference View based on the uid as a contextual filter, but can't figure out how to bring in the default value as well.

0

Ended up doing a somewhat convoluted hack with a custom module.

1) Used 2 Conditional Filters in the View (A- uid of logged in user, b- uid=0)

2) Used regular filter of the taxonomy type (C). Since Conditional Filters are ANDed together as well as ANDed with any normal filters, the derived WHERE logic of View is (A AND B) AND C (which would never return results unless the logged in user was user 0, but the query isn't available to anonymous users).

3) Created a custom module and used the following in hook_views_query_alter: $query->where[0]['type']='OR' So the WHERE logic of the altered view becomes (A OR B) AND C, which gives me the results I wanted.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.