Allow Multiple Values - AND or OR

Created on 21 May 2021, over 3 years ago
Updated 4 September 2023, over 1 year ago

The "Allow multiple values" option only work for ',' AND operator

Here I am considering the same example from Allow multiple value - Issue .

1. Drupal standard installation.
2. Add 3 terms to the tags vocabulary (e.g. Foo, Bar and Foobar).
3. Add new taxonomy reference field to the User: "Visible articles".
4. Edit current user, add just "Foo" and "Bar" to the "Visible articles".
5. Create 4 new articles, 1 tagged "Foo", 1 tagged "Bar", 1 tagged "Foobar", 1 tagged "Foo" and "Bar"
6. Create a view listing all articles.
7. Add a contextual filter for article "Tags".
8. "Provide a default value"; choose "User Field Value" (of course) and choose field "field_visible_articles".
9. In the very bottom now under "MORE" choose "Allow multiple values".
10. Save and check view.

The view shows "Foo" and "Bar" article(s).

In the Default argument plugin, multiple values are imploded with comma-sign if "Allow multiple values" is chosen.

I wanted to use the default use case where values should be imploded with the '+' sign (OR), so I have unchecked the 'Allow multiple values' checkbox. Due to that getArgument method returned a single value (first value from an array) and I have got the wrong result.

To solve this problem, I have built a patch that provides the option to handle multiple values.

Please feel free to correct my understanding!

Feature request
Status

RTBC

Version

1.1

Component

Code

Created by

🇮🇳India nileema19

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇸🇰Slovakia coaston

    Hm...for D10.

    When I applied that patch I can still see only articles FOO and unable to see BAR even I select OR.

    In my case:
    1. User has Taxonomy FOO and BAR (mutli value field - reference)
    2. I have created two articles one with FOO and one with BAR.
    3. I can see only the first value when I apply OR filter in contextual filter so FOO.
    4. If I reorder it in user profile so BAR is the first value - I can see BAR and not FOO even OR is selected.

    Does anyone experience on D10 the same issue ?

  • 🇸🇰Slovakia coaston

    Ah - ignore #7. I forgot to enable it also in "MORE" at the bottom. My bad.
    it works now.

Production build 0.71.5 2024