Change block "label" so thad a title like everything else in the template file (and all other template files)

Created on 11 March 2013, over 12 years ago
Updated 18 March 2025, 6 months ago

Problem/Motivation

Look at this code, it's an inconsistent mess of title_prefix, title_attributes and label!

<div{{ attributes }}>
  {{ title_prefix }}
  {% if label %}
    <h2{{ title_attributes }}>{{ label }}</h2>
  {% endif %}
  {{ title_suffix }}

  <div{{ content_attributes }}>
    {{ content }}
  </div>
</div>

Proposed resolution

The fix: The variables printed in a template file for a title of a block should to be called title.

User interface changes

- none

API changes

- none

Related Issues

#1591806: Change block "subject" so that it's called a (admin_)label like everything else on the theme layer β†’
#1591830: Change comment "subject" so that it's called a title like everything else in the template file (and all other template files) β†’
πŸ“Œ Name variables consistently across all templates (preprocess) Closed: outdated
πŸ“Œ Change node "label" so that it's called a title like everything else in the template file (and all other template files) Postponed: needs info

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

block.module

Created by

πŸ‡ΊπŸ‡ΈUnited States jenlampton

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Quoting myself from πŸ“Œ Change node "label" so that it's called a title like everything else in the template file (and all other template files) Postponed: needs info as it applies here too.

    This issue has gone stale for almost 10 years.

    I'm actually somewhat against this change, label is a consistent Drupalism applied to all entity types. Title is not. E.g in #1939224: Change block "label" so that it's called a title like everything else in the template file (and all other template files) blocks don't have a title, they have a block description or label.

    If anything, the title_prefix/suffix/attributes should be the ones to change?

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    Same comment here.

    To get more developers on Drupal, some "Drupalism" needs to go.

    Developers are typically giving a name to the things they create.

    - Name of the block
    - Name of the variable
    - Name of the function
    - Name of the field

    A label is a tag attached to an item.

    So either we continue putting Drupal in a corner with its "Drupalism" or we adopt more generalized standards.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Will agree with #47 we do use label everywhere else. So are we trying to change everywhere now?

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    From the IS:

     {{ title_prefix }}
      {% if label %}
        <h2{{ title_attributes }}>{{ label }}</h2>
      {% endif %}
      {{ title_suffix }}

    We need to be consistent. Either use β€œDrupalism” or use standards.

    Standards (or the request from the IS:

    {{ title_prefix }}
      {% if title %}
        <h2{{ title_attributes }}>{{ title }}</h2>
      {% endif %}
      {{ title_suffix }}

    Drupalism:

    {{ label_prefix }}
      {% if label %}
        <h2{{ label_attributes }}>{{ label }}</h2>
      {% endif %}
      {{ label_suffix }}

    For consistency, we must not mix both title and label.

    #47 and #49 opt to keep label. So lets make it to:

     {{ label_prefix }}
      {% if label %}
        <h2{{ label_attributes }}>{{ label }}</h2>
      {% endif %}
      {{ label_suffix }}
  • πŸ‡¦πŸ‡ΊAustralia acbramley

    The problem is that would be an extraordinary amount of work. It's not just block using those variable names, there's 56 twig templates alone with this variable in them in core. This spans blocks, comments, fields, media, nodes, search results, taxonomy terms, views, and more. The effort to deprecate title_prefix and title_suffix with BC in mind would be a huge amount of code for what IMO is very little gain.

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    I taught we were discussing drupalism VS standards. And so, speaking about consistency.

    Based on the vast amount of work we might prefer closing this ticket as is.

    Your comment (#51) is self-explanatory. It explains correctly why we won't fix this 12 years old issue.

Production build 0.71.5 2024