Fields excluded via without in template show after installing ui_patterns

Created on 6 June 2025, 21 days ago

Problem/Motivation

I created a card component with a similar structure like the card component in umami, where it is simple to customize the content variable depending on the needs of the template: https://git.drupalcode.org/project/drupal/-/blob/11.x/core/profiles/demo...

For some fields, I only want to check in the component if they have content. So I keep fields in the display (content variable) but do not want to display them. Inside the component I only check if they have content. So in my template I use:

  {% block content %}
    {{ content|without(
      '...'
    ) }}
  {% endblock %}

When I enable ui_patterns, the fields in the without filter suddenly show up via the content variable. There is no further configuration needed.

How can I avoid this?

Steps to reproduce

My full code:

card.twig

{% if project_id %}
  {% set project_id_rendered = project_id|render|striptags|trim %}
  {% set url = '/node/' ~ project_id_rendered ~ offer_link %}
{% endif %}

{# Preserve node vars like contextual links by adding node attributes, classes and header prefix/suffix #}
<{{html_tag|default('article')}}{{ attributes.addClass(classes, 'card') }}>
  <header>
    {{ title_prefix }}
    {{ title_suffix }}
  </header>
  {% if image and view_mode != 'full' %}
    <div class="card__logo {% if user_offer %}card__logo-user{% endif %}">
      <a href="{{ url }}">{{ image }}</a>
    </div>
  {%  endif %}
  <div class="card__title">
    {% if label %}
    <h3>
      {% if link_to_content != 'no' %}<a href="{{ url }}">{{ label }}</a>
      {% else %}
        {{ label }}
      {% endif %}
      </h3>
    {% endif %}
    {% if user_name %}
      <a href="{{ url }}">{{ user_realname }}</a>
    {% endif %}
  </div>
  <div class="card__content text-content">

    {% block content %}{% endblock %}

    {% include "h4d_olive:project-icons" with {
      size: 'size-1',
      link: 'link',
      align: 'justify-center',
      url,
      offers_commercial,
      offers_person,
      offers_invest,
      profile_housing,
      profile_coop,
      profile_provider,
    } %}

  </div>
  {% set project_crumbs_rendered = project_crumbs|render %}
  {% if project_crumbs_rendered %}
    {{ project_crumbs }}
  {% endif %}

</{{html_tag|default('article')}}>

node--h4d-project--h4d-card.html.twig

{# Preserve node classes #}
{%
  set classes = [
  'node',
  'node--type-' ~ node.bundle|clean_class,
  not node.isPublished() ? 'node--unpublished',
  view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
]
%}

{% embed "h4d_olive:card" with {
  content,
  attributes: attributes,
  classes: classes,
  title_prefix: title_prefix,
  title_suffix: title_suffix,
  label: node.label,
  image: content.field_h4d_project_image,
  offers_commercial: content.h4d_offer_commercial_group_content_eva_entity_view_1,
  offers_invest: content.h4d_offer_invest_group_content_eva_entity_view_1,
  offers_person: content.h4d_offer_person_group_content_eva_entity_view_1,
  profile_housing: content.field_h4d_profile_housing,
  profile_provider: content.field_h4d_profile_provider,
  profile_coop: content.field_h4d_profile_coop,
  url: url,
  view_mode: 'h4d-card',
  type: 'project',
  nodeid: node.id,
} %}
  {% block content %}
    {{ content|without(
      'h4d_is_archived',
      'h4d_entity_moderation_form',
      'field_h4d_project_image',
      'h4d_offer_commercial_group_content_eva_entity_view_1',
      'h4d_offer_invest_group_content_eva_entity_view_1',
      'h4d_offer_person_group_content_eva_entity_view_1',
      'field_h4d_profile_housing',
      'field_h4d_profile_coop',
      'field_h4d_profile_provider',
    ) }}
  {% endblock %}
{% endembed %}

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany anruether Bonn

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

Comments & Activities

Production build 0.71.5 2024