/Drupal 8

function hook_theme_suggestions_HOOK_alter

hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables)

Alters named suggestions for a specific theme hook.

This hook allows any module or theme to provide alternative theme function or template name suggestions and reorder or remove suggestions provided by hook_theme_suggestions_HOOK() or by earlier invocations of this hook.

HOOK is the least-specific version of the hook being called. For example, if '#theme' => 'node__article' is called, then node_theme_suggestions_node() will be invoked, not node_theme_suggestions_node__article(). The specific hook called (in this case 'node__article') is available in $variables['theme_hook_original'].

@todo Add @code sample.


array $suggestions: An array of theme suggestions.

array $variables: An array of variables passed to the theme hook. Note that this hook is invoked before any preprocessing.

See also



Related topics

Define functions that alter the behavior of Drupal core.


core/lib/Drupal/Core/Render/theme.api.php, line 714
Hooks and documentation related to the theme and render system.


function hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
  if (empty($variables['header'])) {
    $suggestions[] = 'hookname__' . 'no_header';

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.