Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The variables inside templates are often called $content when what we actually meant was the contents of the template. I propose that we change the variable name form "content" (which in the drupal world seems to mean node) to "contents" which should indicate "the stuff in this template" and confuse people less.
Before:
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<?php print render($title_suffix); ?>
<div<?php print $content_attributes; ?>>
<?php print $content ?>
</div>
</div>
After:
<div id="<?php print $block_html_id; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php print render($title_prefix); ?>
<?php if ($block->subject): ?>
<h2<?php print $title_attributes; ?>><?php print $block->subject ?></h2>
<?php endif;?>
<?php print render($title_suffix); ?>
<div<?php print $contents_attributes; ?>>
<?php print $contents ?>
</div>
</div>
Comments
Comment #0.0
jenlamptonadded code samples
Comment #0.1
jenlamptonline break
Comment #1
star-szrUnfortunately I think it's too late for this for D8, moving to D9.
Comment #2
catchCould we not duplicate the variable and update the templates to use the new one?
Comment #3
lauriiiWe definitely could work on this during 8.x life cycle. I'm not sure if I'm convinced with the proposed solution but I agree that there is confusion caused by the name of this variable. Maybe it would be useful to think what other possible solution there would be.
Comment #4
joelpittetI don't think adding the BC layer and duplicate variable names is worth the effort here. The gain is minor, could duplicate the memory and the variable namespaces doubles for the life of D8
Comment #5
apadernoIs contents the right word? The only definition I find for contents is the list of chapters or articles or parts that are in the book, with the number of the page they begin on.
I think there is a difference between talking of the site content and the content of a template. Users should not get confused between them, since the context is totally different.
Comment #7
xjmBased on #5 and my own lexical inclinations, I think this issue is a wontfix. Thanks!