| 6 core.php | hook_preprocess(&$variables, $hook) |
| 7 theme.api.php | hook_preprocess(&$variables, $hook) |
| 8 theme.api.php | hook_preprocess(&$variables, $hook) |
Preprocess theme variables.
This hook allows modules to preprocess theme variables for theme templates. It is called for all invocations of theme(), to allow modules to add to or override variables for all theme hooks.
For more detailed information, see theme().
Parameters
$variables: The variables array (modify in place).
$hook: The name of the theme hook.
5 functions implement hook_preprocess()
File
- modules/
system/ theme.api.php, line 109
Code
function hook_preprocess(&$variables, $hook) {
static $hooks;
// Add contextual links to the variables, if the user has permission.
if (!user_access('access contextual links')) {
return;
}
if (!isset($hooks)) {
$hooks = theme_get_registry();
}
// Determine the primary theme function argument.
if (isset($hooks[$hook]['variables'])) {
$keys = array_keys($hooks[$hook]['variables']);
$key = $keys[0];
}
else {
$key = $hooks[$hook]['render element'];
}
if (isset($variables[$key])) {
$element = $variables[$key];
}
if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
$variables['title_suffix']['contextual_links'] = contextual_links_view($element);
if (!empty($variables['title_suffix']['contextual_links'])) {
$variables['classes_array'][] = 'contextual-links-region';
}
}
}
Login or register to post comments