Add option to hide extra field with view entirely, if view has no results

Created on 24 September 2024, 4 months ago

Problem/Motivation

If a view added through an extra field is empty, all the wrappers are still printed out and its kind of hard to write a proper empty check for this.

Example:

    {% if product.extra_field_foo_view %}
      {% set view_name = product.extra_field_foo_view.content['#name'] %}
      {% set view_display_name = product.extra_field_foo_view.content['#display'] %}
      {% if drupal_view_result(view_name,view_display_name)|length %}
        <div class="product__x-sells container container--extended">
          {{ product.extra_field_foo_view }}
        </div>
      {% endif %}
    {% endif %}

Would be very nice if this where just something like:

    {% if product.extra_field_foo_view %}
      <div class="product__x-sells container container--extended">
        {{ product.extra_field_foo_view }}
      </div>
    {% endif %}

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024