1

I'm trying to find a way to filter Views through contextual filters based on custom taxonomy term fields. Here is an example:

Content type: Article
Taxonomy vocabulary: Tags
Tags custom field: UniqueString

When I create an article, I assign tags to it. To every tag (taxonomy term) I assign an unique string. Example:

Article title: John Smith's best songs
Tags: John | Guitar
UniqueString for tag John: uid1
UniqueString for tag Guitar: uid2

Now I want to display articles that are tagged with both John and Guitar. This works:

Contextual filters:

Content: Has taxonomy term ID
Content: Has taxonomy term ID

View page path: views/taggedby/%/%

Path views/taggedby/john/guitar will display:

John Smith's best songs

However, I want to filter based on UniqueString value and not on tag names:

Relationships:

Content: Taxonomy terms on node

Contextual filters:

(term) Taxonomy term: UniqueString
(term) Taxonomy term: UniqueString

View page path: views/taggedby2/%/%

Path views/taggedby2/john/guitar will display an empty view. What's confusing is that everything works when there is only one filter and the path is views/taggedby2/%, so there has to be a way to make it work with multiple filters as well. E. g. if I change View page path to views/taggedby2/% and use guitar as an argument, it will display:

John Smith's best songs

How to make it work with two (or more) arguments?

2

I have finally found a solution - it's necessary to add another relationship for the same field :

Content: Taxonomy terms on node, Identifier: term
Content: Taxonomy terms on node, Identifier: term2

The second contextual filter should use the second relationship (term2) and then everything works as expected.

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.