In contextual filters, with

  • validator = taxonomy term
  • Filter value type = term ids separated by , or +
  • allow multiple values = true

Giving argument "1+2" works as espected: OR operator
Giving argument "1,2" works as "1+2": OR operator instead of expected AND operator

In both cases, conditions uses operator "IN"
WHERE (( (field_data_field_tags.field_tags_tid IN('1', '2') ) )AND(( (node.status = '1') AND (node.type IN ('flickr_photo')) )))

This is the contextual filter part of my view:

/* Contextual filter: Content: Tags (field_tags) */
$handler->display->display_options['arguments']['field_tags_tid']['id'] = 'field_tags_tid';
$handler->display->display_options['arguments']['field_tags_tid']['table'] = 'field_data_field_tags';
$handler->display->display_options['arguments']['field_tags_tid']['field'] = 'field_tags_tid';
$handler->display->display_options['arguments']['field_tags_tid']['default_action'] = 'empty';
$handler->display->display_options['arguments']['field_tags_tid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['field_tags_tid']['default_argument_skip_url'] = 0;
$handler->display->display_options['arguments']['field_tags_tid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['field_tags_tid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['field_tags_tid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['arguments']['field_tags_tid']['specify_validation'] = 1;
$handler->display->display_options['arguments']['field_tags_tid']['validate']['type'] = 'taxonomy_term';
$handler->display->display_options['arguments']['field_tags_tid']['validate_options']['vocabularies'] = array(
  'tags' => 'tags',
);
$handler->display->display_options['arguments']['field_tags_tid']['validate_options']['type'] = 'tids';
$handler->display->display_options['arguments']['field_tags_tid']['validate_options']['transform'] = 0;
$handler->display->display_options['arguments']['field_tags_tid']['validate']['fail'] = 'empty';
$handler->display->display_options['arguments']['field_tags_tid']['break_phrase'] = 1;
$handler->display->display_options['arguments']['field_tags_tid']['not'] = 0;

Comments

jastraat’s picture

Version: 7.x-3.1 » 7.x-3.3

Still a problem in the most recent release

mjut’s picture

is there a patch to fix that? should we use the dev-Version of Views?

Alessandro Pezzato’s picture

It works with contextual filter "Content: Has taxonomy term ID".

dawehner’s picture

Status: Active » Fixed

The original creator of the issue said it's fixed now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

RdeBoer’s picture

Title: Taxonomy term AND (,) operator does not works » Contextual filter AND (,) operator for multiple values does not work
Version: 7.x-3.3 » 7.x-3.7
Status: Closed (fixed) » Active

Still totally broken for just about every contextual filter field I tried, including fields that are NOT taxonomy terms.
The same query using IN is genereated whether contextual argument values are separated by a comma or a plus.

Examples?
Simple View with the "Content: Tags (field_tags)" (from the core Article content type).
Or the /glossary View. If you tick "Allow multiple values" on its contextual filter panel, then you'll find that whether you use /glossary/b+w or/glossary/b,w, the same query is executed, namely:

SELECT node.title AS node_title, node.nid AS nid, users_node.name AS users_node_name, users_node.uid AS users_node_uid, node.changed AS node_changed
FROM 
{node} node
LEFT JOIN {users} users_node ON node.uid = users_node.uid
WHERE (( (SUBSTRING(node.title, 1, 1) IN('B', 'W')) ))
ORDER BY node_title ASC
LIMIT 36 OFFSET 0

Naturally, requesting all content titles that start with both B AND W does not make much sense, but the point is that the query should return nothing in that case when in reality it returns the same as B OR W.

fabul’s picture

This issue is not fixed in Drupal 8.
When using two contextual filters %vocabularyid/%termid with relationship on vocabulary.
The execution of view succeed even if termid id not related to vocabulary id.

kelvinwongg’s picture

I have no idea why Drupal still exists with this issue unsolved.