| 6 core.php | hook_theme_registry_alter(&$theme_registry) |
| 7 system.api.php | hook_theme_registry_alter(&$theme_registry) |
| 8 system.api.php | hook_theme_registry_alter(&$theme_registry) |
Alter the theme registry information returned from hook_theme().
The theme registry stores information about all available theme hooks, including which callback functions those hooks will call when triggered, what template files are exposed by these hooks, and so on.
Note that this hook is only executed as the theme cache is re-built. Changes here will not be visible until the next cache clear.
The $theme_registry array is keyed by theme hook name, and contains the information returned from hook_theme(), as well as additional properties added by _theme_process_registry().
For example:
<?php
$theme_registry['user_profile'] = array(
'variables' => array(
'account' => NULL,
),
'template' => 'modules/user/user-profile',
'file' => 'modules/user/user.pages.inc',
'type' => 'module',
'theme path' => 'modules/user',
'preprocess functions' => array(
0 => 'template_preprocess',
1 => 'template_preprocess_user_profile',
),
);
?>
Parameters
$theme_registry: The entire cache of theme registry information, post-processing.
See also
Related topics
File
- modules/
system/ system.api.php, line 2217 - Hooks provided by Drupal core and the System module.
Code
<?php
function hook_theme_registry_alter(&$theme_registry) {
// Kill the next/previous forum topic navigation links.
foreach ($theme_registry['forum_topic_navigation']['preprocess functions'] as $key => $value) {
if ($value == 'template_preprocess_forum_topic_navigation') {
unset($theme_registry['forum_topic_navigation']['preprocess functions'][$key]);
}
}
}
?> Login or register to post comments
Comments
How do you implement changes
How do you implement changes to only specific pages? I've implemented this function in a custom module, but it is effecting every page in my site, which is not the intent.
Theme registry is for all themes and all pages
This function is fired once to build everything for all themes on all pages. If you want to modify a theme for some pages, I suggest you set up a subtheme for those pages and use something like the themekey module to show the subtheme on the special pages. You can then alter the subtheme.