function hook_preprocess_HOOK
Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess_HOOK()
- 10 core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess_HOOK()
- 11.x core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess_HOOK()
Preprocess theme variables for a specific theme hook.
This hook allows modules to preprocess theme variables for a specific theme hook. It should only be used if a module needs to override or add to the theme preprocessing for a theme hook it didn't define.
For more detailed information, see the Theme system overview topic.
Parameters
$variables: The variables array (modify in place).
Related topics
186 functions implement hook_preprocess_HOOK()
Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.
- aggregator_preprocess_block in core/
modules/ aggregator/ aggregator.module - Implements hook_preprocess_HOOK() for block templates.
- comment_preprocess_block in core/
modules/ comment/ comment.module - Implements hook_preprocess_HOOK() for block templates.
- comment_preprocess_field in core/
modules/ comment/ comment.module - Prepares variables for comment field templates.
- common_test_preprocess_common_test_render_element in core/
modules/ system/ tests/ modules/ common_test/ common_test.module - Implements MODULE_preprocess_HOOK().
- content_moderation_preprocess_node in core/
modules/ content_moderation/ content_moderation.module - Implements hook_preprocess_HOOK().
File
-
core/
lib/ Drupal/ Core/ Render/ theme.api.php, line 588
Code
function hook_preprocess_HOOK(&$variables) {
// This example is from rdf_preprocess_image(). It adds an RDF attribute
// to the image hook's variables.
$variables['attributes']['typeof'] = [
'foaf:Image',
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.