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

#1939224: Change block "label" so thad 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)
#1825216: Name variables consistently across all templates (preprocess)
#2004966: Markup and variable cleanup for titles and attributes in all templates

Comments

jenlampton’s picture

Issue summary: View changes

other

jenlampton’s picture

Issue summary: View changes

less snark

xmacinfo’s picture

I do not understand the need to call the label() method on the node object. Nevertheless, in the node template I agree, we should have $title, not $label.

The decision should be simple, use $title everywhere we need to display a title.

xmacinfo’s picture

Issue summary: View changes

A

dead_arm’s picture

Issue summary: View changes

Add related issue

xjm’s picture

Component: node.module » node system
Issue summary: View changes

(Merging "node system" and "node.module" components for 8.x; disregard.)

joelpittet’s picture

Status: Active » Needs review
StatusFileSize
new4.98 KB
  • label to title
  • moved title_suffix/prefix up closer to the title in the dockbock
  • fixed one 80char doc issue.

Let's see if testbot has any grievances.

mlncn’s picture

Status: Needs review » Needs work

The last submitted patch, 3: 1939234-node-label-to-title-3.patch, failed testing.

mlncn’s picture

Issue tags: +Needs reroll

Worked 3 months ago so probably just needs re-roll.

lahoosascoots’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.4 KB

Re-rolled

xmacinfo’s picture

Green! Do we need to patch only three files?

berdir’s picture

I'm honestly not sure why node of all things was updated to use label, but the advantage of label is that it's the generic name on the entity level.

Comments have subjects (uses title in the template too, that's also weird), terms (uses name) and users have names (doesn't use anything in the template). All those things are exposed as the entity label.

But completely agree that having title_* and then label is weird., would have to be renamed consistently to label, better to be title consistently than what we have right now.

I suggest that you also update the $node->label() call to $node->getName(), wherever it's set.

Status: Needs review » Needs work

The last submitted patch, 7: 1939234-node-label-to-title-7.patch, failed testing.

mgifford’s picture

Issue tags: +Needs reroll
Sethie’s picture

Assigned: Unassigned » Sethie

I'll reroll it.

Sethie’s picture

Status: Needs work » Needs review
StatusFileSize
new4.45 KB

Here's the patch.

Vikas.Kumar’s picture

Issue tags: -consistency, -Twig, -theme system cleanup, -Needs reroll +#SprintWeekend2015
StatusFileSize
new3.57 KB
Vikas.Kumar’s picture

Issue tags: -#SprintWeekend2015 +SprintWeekend2015
xmacinfo’s picture

Issue summary: View changes

Well done!

I did not apply the patch, though, so not marking RTBC.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

I applied the patch. Looks like a good change for consistency.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 15: 1939234-node-label-to-title-15.patch, failed testing.

Status: Needs work » Needs review
lauriii’s picture

Status: Needs review » Reviewed & tested by the community

Putting back because of random test failure

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

I guess the beta evaluation could be added there actually..

xmacinfo’s picture

@lauriii: What do you mean by:

I guess the beta evaluation could be added there actually.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: 1939234-node-label-to-title-15.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: 1939234-node-label-to-title-15.patch, failed testing.

star-szr’s picture

Version: 8.0.x-dev » 9.x-dev
Assigned: Sethie » Unassigned
Status: Needs work » Postponed

Sorry, indeed this stuff is a bit of a mess as far as consistency, but postponing for the same reasons as #1939224-28: Change block "label" so thad a title like everything else in the template file (and all other template files).

catch’s picture

Version: 9.x-dev » 8.1.x-dev

I think we could duplicate the variable and update the template in a minor release, then remove the duplication in 9.x

Doesn't make it less messy in 8.x, but it does make it forward compatible with a less-messy 9.x.

berdir’s picture

We could but the problem there is modules that are altering it in preprocess, they'd have to be updated to support both.

catch’s picture

We could do the duplication after preprocess runs.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture

Status: Postponed » Postponed (maintainer needs more info)

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 thad 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?

xmacinfo’s picture

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.

acbramley’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

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 :)