Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess()
  2. 7.x modules/system/theme.api.php \hook_preprocess()
  3. 8.9.x core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess()
  4. 9 core/lib/Drupal/Core/Render/theme.api.php \hook_preprocess()

Preprocess theme variables for template files.

This hook allows modules to preprocess theme variables for theme templates. It is only called for theme hooks implemented as template files, but not for those implemented as theme functions. The purpose of this hook is to allow modules to add to or override variables for all template files.

For more detailed information, see theme().

Parameters

$variables: The variables array (modify in place).

$hook: The name of the theme hook.

Related topics

2 functions implement hook_preprocess()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

search_invoke_preprocess in modules/search/search.module
Invokes hook_search_preprocess() in modules.
template_preprocess in includes/theme.inc
Adds a default set of helper variables for preprocess functions and templates. This comes in before any other preprocess function which makes it possible to be used in default theme implementations (non-overriden theme functions).

File

developer/hooks/core.php, line 2282
These are the hooks that are invoked by the Drupal core.

Code

function hook_preprocess(&$variables, $hook) {

  // Add the name of the current theme hook as a variable
  $variables['theme_hook'] = $hook;
}