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.

Parameters

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

hook_theme_suggestions_alter()

hook_theme_suggestions_HOOK()

Related topics

Hooks
Define functions that alter the behavior of Drupal core.

File

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

Code

function hook_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
  if (empty($variables['header'])) {
    $suggestions[] = 'hookname__' . 'no_header';
  }
}
doc_Drupal
2016-10-29 09:18:32
Comments
Leave a Comment

Please login to continue.