Change node "label" so that it's called a title like everything else in the template file (and all other template files)

Created on 11 March 2013, about 12 years ago
Updated 18 March 2025, about 2 months ago

Problem/Motivation

Look at this code, this is an inconsistent mess:

 <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
  <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>" rel="bookmark"><?php print $label; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?> 

Proposed resolution

I understand the need to call the label() method on the node object instead of directly referencing the $node->title, but I don't understand why that needs to trickle all the way down to the theme layer. Can we please be consistent with our variable names and call this a title? We can preprocess it in, or do it as part of the Twig __to_string() method on rendering a node.title but in the template file we should really be calling this a title.

Alternatively, we could rename everything else in these templates that contains "title" into a label. label_prefix, label_suffix, label_attributes.

Remaining tasks

- make our templates consistent

User interface changes

- none

API changes

- none

Related Issues

#1939224: Change block "label" so that it's called a title like everything else in the template file (and all other template files) β†’
#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
πŸ“Œ Markup and variable cleanup for titles and attributes in all templates Active

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

node system

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

    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

    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.

  • πŸ‡¦πŸ‡ΊAustralia acbramley

    Thinking about this more, I think label is the better name to keep. We use it all over the place in Drupal such as in entity keys, other entity metadata keys (label_count), $entity->label() and many other areas.

    Repeating #48 if anything I think title_prefix/suffix/attributes should be the thing to change but I don't feel strongly enough to open a follow up. If anyone else does, feel free :)

Production build 0.71.5 2024