The Definitive Guide to Drupal 7

Notable Render Arrays in Core Templates

There are quite a few render array variables scattered across core templates that are worth noting. hook_page_alter() contains the entire page so it can always be used to alter anything. However, finding that particular anything is not always trivial as other modules can move stuff around, so using more specific alters is advised. Table 16–2 is a quick reference of notable render arrays. This is by no means a full list, but it covers quite a bit and should give you an idea of how to begin figuring out where to look to edit these things.

Table 16–2. Notable render arrays in core templates.
Variable Found In Alter Hook Description
$page page.tpl.php hook_page_alter() Contains the entire page from regions down to fields and comments.
$content node.tpl.php, comment.tpl.php, taxonomy-term.tpl.php hook_node_view_alter(), hook_comment_view_alter(), hook_taxonomy_term_view_alter() Contains the contents of each entity. For more details see http://api.drupal.org/hook_entity_view_alter.
$tabs page.tpl.php hook_menu_local_tasks_alter() Contains primary and secondary tabs, themable via theme_menu_local_tasks() and theme_menu_local_task().
$action_links page.tpl.php hook_menu_local_tasks_alter() Contains action links, themable via theme_menu_local_actions().
$item field.tpl.php hook_field_display_alter() and hook_field_display_ENTITY_TYPE_ alter() Contains display settings for fields, which can adjust label settings or control the formatter used to display the contents of field.tpl.php.

You are reading content from two chapters on Theme Development from The Definitive Guide to Drupal 7, written by Jacine Luisi and published by Apress on July 19, 2011. All rights reserved.