Heading
In Drupal 7 (and all prior versions), headings are hard-coded in templates like block.tpl.php
and node.tpl.php
. This worked well when the content followed the same general structure. That was all that was needed. Prior to Drupal, we didn't have Contextual links, Shortcut module or HTML5. We didn't have a need inject content before and after these titles, and it was fairly easy to tweak headings because we didn't need to worry about properly sectioning content.
In Drupal 7 these injected pieces of content were implemented using the render API, building off the existing #prefix
and #suffix
idea in Form API and dumped in block.tpl.php
and node.tpl.php
. While these variables exist globally and can be extended, the problem is these variables are poorly named, rarely understood and not useful outside of the templates where they actually print without having to re-implement the pattern again manually, which can be extensive.
The fact is that a "heading" or title, whether it's visible or not should exist for most of our content.
Title
[shortcut]HTML source
[contextual]
<h1>Title</h1>
[shortcut]
PHP source
<?php foreach ($items as $item): ?>
<<?php print $item['tag']; ?><?php print $item['attributes']; ?>>
<?php print render($item); ?>
</<?php print $item['tag']; ?>>
<?php endforeach; ?>