0

I am adding taxonomy terms to groups (using the group module) and want to use the terms to filter groups within a view. However, my exposed filters don't seem to work. There is no error, but the behavior of filters is not what I expect.

When I request the display of A-term groups and B-term groups (from two different vocabularies), the view displays nothing. It is not logic.

Question: is group module compatible with taxonomy core module? I mean: is it possible to add taxonomy terms directly to groups (and not group contents)?

Here is my view:

uuid: 152ca6c2-f625-43db-8f2a-efa020ff5dd3
langcode: fr
status: true
dependencies:
  config:
    - field.storage.group.field_locate_place
    - field.storage.group.field_place_type
    - taxonomy.vocabulary.existing_places
    - taxonomy.vocabulary.projects
  module:
    - address
    - better_exposed_filters
    - group
    - leaflet
    - leaflet_views
    - link
    - taxonomy
id: map
label: Map
module: views
description: ''
tag: ''
base_table: groups_field_data
base_field: id
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: none
        options: {  }
      cache:
        type: tag
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      exposed_form:
        type: bef
        options:
          submit_button: Filter
          reset_button: true
          reset_button_label: Remove
          exposed_sorts_label: 'Sort by'
          expose_sort_order: false
          sort_asc_label: Asc
          sort_desc_label: Desc
          text_input_required: 'Sélectionnez n''importe quel filtre et cliquez sur Appliquer pour voir les résultats'
          text_input_required_format: restricted_html
          bef:
            general:
              autosubmit: false
              autosubmit_exclude_textfield: false
              autosubmit_textfield_delay: 500
              autosubmit_hide: false
              input_required: false
              allow_secondary: false
              secondary_label: 'Options avancées'
              secondary_open: false
            filter:
              field_place_type_target_id:
                plugin_id: default
                advanced:
                  rewrite:
                    filter_rewrite_values: ''
                  collapsible: false
                  is_secondary: false
              field_place_type_target_id_1:
                plugin_id: default
                advanced:
                  rewrite:
                    filter_rewrite_values: ''
                  collapsible: false
                  is_secondary: false
      pager:
        type: some
        options:
          items_per_page: 1000
          offset: 0
      style:
        type: leaflet_map
        options:
          grouping: {  }
          data_source: field_locate_place
          entity_source: __base_table
          name_field: label
          description_field: ''
          view_mode: token
          leaflet_map: 'OSM Mapnik'
          height: '700'
          height_unit: px
          hide_empty_map: false
          disable_wheel: true
          fullscreen_control: true
          gesture_handling: false
          reset_map:
            control: false
            position: topright
          map_position:
            force: true
            center:
              lat: 46
              lon: 2
            zoom: 6
            minZoom: 1
            maxZoom: 16
            zoomFiner: 0
          weight: ''
          icon:
            iconType: marker
            iconUrl: ''
            shadowUrl: ''
            className: ''
            html: '<div></div>'
            html_class: leaflet-map-divicon
            circle_marker_options: '{"radius":100,"color":"red","fillColor":"#f03","fillOpacity":0.5}'
            iconSize:
              x: ''
              'y': ''
            iconAnchor:
              x: ''
              'y': ''
            shadowSize:
              x: ''
              'y': ''
            shadowAnchor:
              x: ''
              'y': ''
            popupAnchor:
              x: ''
              'y': ''
          leaflet_markercluster:
            control: true
            options: '{"spiderfyOnMaxZoom":true,"showCoverageOnHover":true,"removeOutsideVisibleBounds":false}'
          path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
          geocoder:
            control: false
            settings:
              position: topright
              input_size: 25
              providers:
                kml_file:
                  weight: '0'
                  checked: 0
                openstreetmap:
                  weight: '0'
                  checked: 0
              min_terms: 4
              delay: 800
              zoom: 16
              popup: false
              options: ''
      row:
        type: 'entity:group'
        options:
          relationship: none
          view_mode: default
      fields:
        field_locate_place:
          id: field_locate_place
          table: group__field_locate_place
          field: field_locate_place
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: value
          type: leaflet_formatter_default
          settings:
            multiple_map: false
            popup: true
            popup_content: "[group:title]\r\n[group:field_place_type]\r\n[group:url]\r\n\r\n\r\n"
            leaflet_map: 'OSM Mapnik'
            height: 700
            height_unit: px
            hide_empty_map: false
            disable_wheel: true
            fullscreen_control: true
            gesture_handling: false
            reset_map:
              control: false
              position: topright
            map_position:
              force: true
              center:
                lat: 46.5
                lon: 2.5
              zoom: 6
              minZoom: 1
              maxZoom: 16
              zoomFiner: 0
            weight: ''
            icon:
              iconType: marker
              iconUrl: ''
              shadowUrl: ''
              className: ''
              html: '<div></div>'
              html_class: leaflet-map-divicon
              circle_marker_options: '{"radius":100,"color":"red","fillColor":"#f03","fillOpacity":0.5}'
              iconSize:
                x: ''
                'y': ''
              iconAnchor:
                x: ''
                'y': ''
              shadowSize:
                x: ''
                'y': ''
              shadowAnchor:
                x: ''
                'y': ''
              popupAnchor:
                x: ''
                'y': ''
            leaflet_markercluster:
              control: true
              options: '{"spiderfyOnMaxZoom":true,"showCoverageOnHover":true,"removeOutsideVisibleBounds":false}'
            path: '{"color":"#3388ff","opacity":"1.0","stroke":true,"weight":3,"fill":"depends","fillColor":"*","fillOpacity":"0.2","radius":"6"}'
            geocoder:
              control: false
              settings:
                position: topright
                input_size: 25
                providers:
                  kml_file:
                    weight: 0
                    checked: false
                  openstreetmap:
                    weight: 0
                    checked: false
                min_terms: 4
                delay: 800
                zoom: 16
                popup: false
                options: ''
          group_column: value
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          plugin_id: field
        view_group:
          id: view_group
          table: groups
          field: view_group
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: true
          alter:
            alter_text: false
            text: ''
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          text: voir
          output_url_as_text: false
          absolute: false
          entity_type: group
          plugin_id: entity_link
        label:
          id: label
          table: groups_field_data
          field: label
          relationship: none
          group_type: group
          admin_label: ''
          label: ''
          exclude: false
          alter:
            alter_text: true
            text: "<div>\r\n    {{ label }}\r\n    {{ field_locate_place }}\r\n    {{ field_place_type }}\r\n    {{ view_group }}\r\n</div>\r\n\r\n    \r\n    "
            make_link: false
            path: ''
            absolute: false
            external: false
            replace_spaces: false
            path_case: none
            trim_whitespace: false
            alt: ''
            rel: ''
            link_class: ''
            prefix: ''
            suffix: ''
            target: ''
            nl2br: false
            max_length: 0
            word_boundary: true
            ellipsis: true
            more_link: false
            more_link_text: ''
            more_link_path: ''
            strip_tags: false
            trim: false
            preserve_tags: ''
            html: false
          element_type: ''
          element_class: ''
          element_label_type: ''
          element_label_class: ''
          element_label_colon: false
          element_wrapper_type: ''
          element_wrapper_class: ''
          element_default_classes: true
          empty: ''
          hide_empty: false
          empty_zero: false
          hide_alter_empty: true
          click_sort_column: value
          type: string
          settings:
            link_to_entity: true
          group_column: value
          group_columns: {  }
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
          entity_type: null
          entity_field: label
          plugin_id: field
      filters:
        field_place_type_target_id:
          id: field_place_type_target_id
          table: group__field_place_type
          field: field_place_type_target_id
          relationship: none
          group_type: group
          admin_label: ''
          operator: or
          value: {  }
          group: 1
          exposed: true
          expose:
            operator_id: field_place_type_target_id_op
            label: 'Place type'
            description: null
            use_operator: false
            operator: field_place_type_target_id_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: field_place_type_target_id
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: true
          group_info:
            label: 'Existing places'
            description: ''
            identifier: field_place_type_target_id
            optional: true
            widget: radios
            multiple: true
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items:
              1:
                title: 'place A'
                operator: or
                value:
                  82: '82'
              2:
                title: 'place B'
                operator: or
                value:
                  83: '83'
              3:
                title: 'place C'
                operator: or
                value:
                  84: '84'
          reduce_duplicates: false
          type: select
          limit: true
          vid: existing places
          hierarchy: false
          error_message: true
          plugin_id: taxonomy_index_tid
        field_place_type_target_id_1:
          id: field_place_type_target_id_1
          table: group__field_place_type
          field: field_place_type_target_id
          relationship: none
          group_type: group
          admin_label: ''
          operator: or
          value: {  }
          group: 1
          exposed: true
          expose:
            operator_id: field_place_type_target_id_1_op
            label: 'Place type'
            description: null
            use_operator: false
            operator: field_place_type_target_id_1_op
            operator_limit_selection: false
            operator_list: {  }
            identifier: field_place_type_target_id_1
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: true
          group_info:
            label: Projects
            description: ''
            identifier: field_place_type_target_id_1
            optional: true
            widget: radios
            multiple: true
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items:
              1:
                title: 'project 1'
                operator: or
                value:
                  85: '85'
              2:
                title: 'project 2'
                operator: or
                value:
                  86: '86'
              3:
                title: 'project 3'
                operator: or
                value:
                  87: '87'
          reduce_duplicates: false
          type: select
          limit: true
          vid: projects
          hierarchy: false
          error_message: true
          plugin_id: taxonomy_index_tid
      sorts: {  }
      title: 'Map'
      header: {  }
      footer: {  }
      empty: {  }
      relationships: {  }
      arguments: {  }
      display_extenders: {  }
      filter_groups:
        operator: OR
        groups: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - user
      tags:
        - 'config:field.storage.group.field_locate_place'
  page_1:
    display_plugin: page
    id: page_1
    display_title: 'Map'
    position: 1
    display_options:
      display_extenders: {  }
      path: node
      display_description: ''
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - user
      tags:
        - 'config:field.storage.group.field_locate_place'
4
  • It is possible to add fields to groups. Taxonomy is also fine. Are you using one filter and selecting A-term and B-term? or is A-term selected in one filter and B-term selected in a second filter?
    – sonfd
    Jan 15, 2021 at 13:06
  • Here is my taxonomy structure: - vocabulary A : terms A1, A2, A3 - vocabulary B : terms B1, B2, B3 and my group structure: - group A1 : terms A1 - group A2 : terms A3 - group A3 : terms A3 - group B1 : terms B1 - group B2 : terms B2 - group B3 : terms B3 Jan 15, 2021 at 13:13
  • So you're putting Term A as the value for one filter and Term B as the value for a second filter? (when you are filtering the view and getting your unexpected results)
    – sonfd
    Jan 15, 2021 at 13:19
  • as long as the fields are left empty the view is correct, but if I select a combination of fields I no longer have any results. Yet I put a OR in the filters Jan 15, 2021 at 13:29

2 Answers 2

1

By default, all Filters get added to the same Filter Group (a filter group is just a group of filters that share a logical operator, e.g. AND or OR). The default behavior is to put all filters into the same group with the logical operator AND. This means that if you have Filter A, Filter B, and Filter C, the view will only produce results that have the value from each filter, Filter A, Filter B and Filter C.

You can review your filter operators and grouping by clicking the Dropdown Button for Filter Criteria and choosing the And/Or Rearrange option.

Views Filter Criteria And/Or Rearrange screen showing Filter A, Filter B, and Filter C in one filter group with logical operator AND

However, it sounds like you want Filter B and Filter C to use an OR Filter group, i.e. you want the view to show results where the content has the value from Filter B or has the value from Filter C.

To do this, you need to make sure that Filter B and Filter C are in their own Filter group and that group's logical operator is set to OR. If you only have the two filters, you can use the original grouping, but change the operator. However, if you have other filters, e.g. my example with 3 filters, you'll need to create a new group.

After you create a second filter group, you'll see that you can control the operator for each filter group and you can also control the operator between the filter groups.

In an example with Filters A, B, and C, if I want to display all results where content has the value from Filter A AND the content has the value from Filter B OR Filter C, I would create two filter groups:

  1. Group 1: with only Filter A
  2. Group 2: with Filter B and Filter C

I would then set the logical operators:

  • Group 1's logical operator would be set to AND (the default, there's only one filter here so it shouldn't matter).
  • Group 2's logical operator would be set to OR (as we want to get results where the content matches either of the Filter B or Filter C, it does not need to match both).
  • The operator between Group 1 and Group 2 would be set to AND

Views Filter Criteria And/Or Rearrange screen showing Filter A in one Filter Group with logical operator AND, Filter B and Filter C in a second filter group with logical operator OR, with the AND operator between the two groups

0

I do not think that there is a way to do that unless I do not understand the question correctly.

Group (Types) are meant to be used as content types and thus you can not attach taxonomy terms directly to them. Groups are meant to be used as nodes. If you want all the groups in a specific group type to belong to certain taxonomy term then you can maybe work something out with the default value of the reference field.

Now concerning your question specifically, i would first check if there is any mistake in the view's configuration. If I get this right, you wish to display groups that belong to terms A.term and B.term so your are probably using the combined filter. Could you share your view configuration, in order to further examine your issue?

1
  • My answers : 1) views is correctly set, I have no error nor warning, 2) The vocabulary are correctly set: Group types have a taxonomy type field whereas groups have taxonomy terms. There is a problem with exposed filters. Let me export my view Jan 15, 2021 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.