function UmamiHooks::themeSuggestionsFieldAlter

Implements hook_theme_suggestions_HOOK_alter() for field templates.

Adds a view mode based suggestion so that a field can be themed for one view mode only, as the recipe badges are.

Attributes

#[Hook('theme_suggestions_field_alter')]

File

core/profiles/demo_umami/themes/umami/src/Hook/UmamiHooks.php, line 62

Class

UmamiHooks
Hook implementations for umami.

Namespace

Drupal\umami\Hook

Code

public function themeSuggestionsFieldAlter(array &$suggestions, array $variables) : void {
  $element = $variables['element'];
  if (isset($element['#view_mode'])) {
    $suggestions[] = 'field__' . $element['#entity_type'] . '__' . $element['#field_name'] . '__' . $element['#bundle'] . '__' . $element['#view_mode'];
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.