2

I am using Views 3 on Drupal 7.

I have a node with multiple terms, and I want to get nodes with all own tids at once.

I configure the contextual filter using the following values:

  • Specify validation criteria:
    • taxonomy term
    • my vocabulary
    • Term IDs separated by , or +
  • Checkbox "Allow multiple values" is on.

I try to pass '1,2' as argument to the view, and I get:

node 1 (tid 1)
node 1 (tid 1, 2)
node 2 (tid 2)
node 3 (tid 2)

By the way, the '1+2' argument gives me the same thing, and it's all right.

Why can't I get a result like the following?

node 1 (tid 1, 2)

Do you have any suggestions?

1 Answer 1

2

The problem is the way this is stored (1 to many relationship). There is no simple way of asking for nodes with terms 1 and 2.

To query for nodes they way you describe you would have to select nodes that has tid 1 and the nid is in a list of nodes that has tid 2. This is possible to do, but not something views support AFAIK.

To get this list, it would be easier to create the query yourself, or resort to hook_query_views_alter, which easily gives problems when maintaining.

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.