I've currently got a view on a Node type (Prospects) where part of the filtering is a Contextual filter filtering a 'Sales Region' taxonomy field against a Sales Regions taxonomy field in the User. The idea is that, given a path of, e.g., /user/4/prospects, the view should only show Prospects whose (single) Sales Region term matches one of those in the Sales Regions terms for user 4. This is actually currently working quite nicely.

The problem comes in that we have just added another pair of taxonomy fields to the Prospect and User - a Company field in each. The User has one Company term, and the Prospect can have multiple. The idea is to additionally limit the Prospects shown to those who have a Company Term that matches the selected user's Company Term. The issue (which I realized when I tried to modify the view to handle this) is that I essentially need to tie the one Contextual Field (a UID) to two different Relations - one for the user's Sales Region field, and one for the Company field, but the Contextual Field UI only appears to allow tying it to one Relation. Is there actually a way to do this, or am I going to have to do something like write a custom filter to handle the additional Company filter?

  • I don't get your setup. Your working view has one contextual filter. First it is on Sales Region Taxonomy, then later on it becomes the UID. And is your taxonomy field of 'Sales Region' the same field on both user and Prospects, or are they different fields using the same taxonomy (sounds like it as one is single-value, and the other multi-value)? You need to provide the exact setup of your content type, user fields, and view (exact relationships added etc) and then I will attempt it. – J. Reynolds Jan 6 '15 at 4:39

A colleague and I got this figured out after I posted the question.

To clarify the original question: the situation is, you've got a view with a path with one argument (e.g. user/%/prospects, where the argument is expected to be a uid), but you need to use that argument in two different contextual filters - in my case, two different taxonomy comparisons between the selected user and the content I've viewing. The problem is, a contextual filter only lets you reference one relation.

The solution is to enter both contextual filters, but in the second one, in the "WHEN THE FILTER VALUE IS NOT IN THE URL" section, choose 'Provide default value', and in the type, choose (in this particular case) "User ID from URL". Other 'from URL' types are available. This allows you to 'share' one argument with two different contextual filters.

| improve this answer | |

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.