Get grandparent node in views block

Created on 3 July 2023, over 1 year ago

Evening everyone :)

I have the following scenario:
- a node type "TV show" with a paragraph (called "field_episodes") to reference a node of the type "Episode"
- a node type "Episode" with a paragraph (called "field_crew") to reference a node of the type "Person"

Now I'm trying to add a views block to show on every "Person" node that shows in which TV shows said person was part of the crew. So I want to get the grandparent's data in the view.

Everything works well with the parent entity by adding a contextual filter of the Paragraph field "field_person" (a field of the field_crew paragraph that references the "Person" content type) and a relationship "Relate each Content with a field_crew set to the Paragraph". I can add a title field with the relationship "field_crew" that show the episode title in which that person was part of the crew.

However, I can't get the grandparent data. I tried to add another relationship "Relate each Content with a field_episodes set to the Paragraph" and a title field with the relationship "field_episodes", but that returns simply an empty field. So it seems to me that I can't establish that "chained" relationship.

This is the exported view, working up to parent but not up to grandparent:

uuid: a9569efa-dde3-4e09-9583-8af35aab9e75
langcode: en
status: true
dependencies:
  config:
    - paragraphs.paragraphs_type.crew
  module:
    - node
    - paragraphs
id: filmography_crew
label: 'Filmography Crew'
module: views
description: ''
tag: ''
base_table: paragraphs_item_field_data
base_field: id
display:
  default:
    id: default
    display_title: Default
    display_plugin: default
    position: 0
    display_options:
      title: 'Filmography Crew'
      fields:
        title:
          id: title
          table: node_field_data
          field: title
          relationship: reverse__node__field_crew_target_id
          group_type: group
          admin_label: ''
          entity_type: node
          entity_field: title
          plugin_id: field
          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: 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
        title_1:
          id: title_1
          table: node_field_data
          field: title
          relationship: reverse__node__field_episodes_target_id
          group_type: group
          admin_label: ''
          entity_type: node
          entity_field: title
          plugin_id: field
          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: 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
      pager:
        type: some
        options:
          offset: 0
          items_per_page: 5
      exposed_form:
        type: basic
        options:
          submit_button: Apply
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      access:
        type: none
        options: {  }
      cache:
        type: tag
        options: {  }
      empty: {  }
      sorts: {  }
      arguments:
        field_person_target_id:
          id: field_person_target_id
          table: paragraph__field_person
          field: field_person_target_id
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: numeric
          default_action: default
          exception:
            value: all
            title_enable: false
            title: All
          title_enable: false
          title: ''
          default_argument_type: node
          default_argument_options: {  }
          default_argument_skip_url: false
          summary_options:
            base_path: ''
            count: true
            override: false
            items_per_page: 25
          summary:
            sort_order: asc
            number_of_records: 0
            format: default_summary
          specify_validation: false
          validate:
            type: none
            fail: 'not found'
          validate_options: {  }
          break_phrase: false
          not: false
      filters:
        status:
          id: status
          table: paragraphs_item_field_data
          field: status
          entity_type: paragraph
          entity_field: status
          plugin_id: boolean
          value: '1'
          group: 1
          expose:
            operator: ''
        type:
          id: type
          table: paragraphs_item_field_data
          field: type
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraph
          entity_field: type
          plugin_id: bundle
          operator: in
          value:
            crew: crew
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            operator_limit_selection: false
            operator_list: {  }
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
      style:
        type: default
      row:
        type: fields
      query:
        type: views_query
        options:
          query_comment: ''
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_tags: {  }
      relationships:
        reverse__node__field_crew_target_id:
          id: reverse__node__field_crew_target_id
          table: paragraphs_item_field_data
          field: reverse__node__field_crew_target_id
          relationship: none
          group_type: group
          admin_label: field_crew
          entity_type: paragraph
          plugin_id: entity_reverse
          required: true
        reverse__node__field_episodes_target_id:
          id: reverse__node__field_episodes_target_id
          table: paragraphs_item_field_data
          field: reverse__node__field_episodes_target_id
          relationship: none
          group_type: group
          admin_label: field_episodes
          entity_type: paragraph
          plugin_id: entity_reverse
          required: true
      header: {  }
      footer: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
      tags: {  }
  block_1:
    id: block_1
    display_title: Block
    display_plugin: block
    position: 1
    display_options:
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
      tags: {  }

Any help would be appreciated. Please let me know if I need to provide additional info.

💬 Support request
Status

Active

Version

1.15

Component

User interface

Created by

🇨🇭Switzerland maenjuel

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

Comments & Activities

Production build 0.71.5 2024