Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
jastraat CreditAttribution: jastraat commentedStill a problem in the most recent release
Comment #2
mjut CreditAttribution: mjut commentedis there a patch to fix that? should we use the dev-Version of Views?
Comment #3
Alessandro Pezzato CreditAttribution: Alessandro Pezzato commentedIt works with contextual filter "Content: Has taxonomy term ID".
Comment #4
dawehnerThe original creator of the issue said it's fixed now.
Comment #6
RdeBoerStill 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:
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.
Comment #7
fabul CreditAttribution: fabul as a volunteer commentedThis 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.
Comment #8
kelvinwongg CreditAttribution: kelvinwongg commentedI have no idea why Drupal still exists with this issue unsolved.