Use filter "Has taxonomy term ID (with depth)" for a specific field

Created on 4 February 2020, almost 5 years ago
Updated 23 February 2023, over 1 year ago

The filter "Has taxonomy term ID (with depth)" works, but it's not possible to apply it for a certain entity reference field.

Steps to reproduce (Example)

  1. Create a content type "Flight" with two fields, "field_country_origin" and "field_country_destination"
  2. Create a content based view with the contextual filter "Has taxonomy term ID (with depth)"
  3. Create a taxonomy vocabulary "Countries" and add some countries and states beneath them, like so:
  • USA
    • Kentucky
  • UK
    • Wales
  • Add contents of type "Flight", like so:
    • Node 1 - field_country_origin = Kentucky, field_country_destination = Wales
    • Node 2 - field_country_origin = Wales, field_country_destination = Kentucky
  • Suppose we want to list flights by origin. Inserting the USA term id on the contextual filter gives both nodes, instead of returning just the correct one (node 1)
  • Proposed Solution

    Have the "with depth" option for each field. In this case, we would have the options Origin Country (field_country_origin:with_depth) and Destination Country (field_country_destination:with_depth)

    I understand there are other ways to achieve what we want in this example, but this one is just illustrative. In my case I have 5 taxonomy depth levels and the query is very slow when relating through all ancestors.

    Thank you.

    ✨ Feature request
    Status

    Active

    Version

    9.5

    Component
    ViewsΒ  β†’

    Last updated about 8 hours ago

    Created by

    Live updates comments and jobs are added and updated live.
    • views

      Involves, uses, or integrates with views. In Drupal 8 core, use the β€œVDC” tag instead.

    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.

    Production build 0.71.5 2024