function umami_preprocess_field
Same name in other branches
- 9 core/profiles/demo_umami/themes/umami/umami.theme \umami_preprocess_field()
- 8.9.x core/profiles/demo_umami/themes/umami/umami.theme \umami_preprocess_field()
- 10 core/profiles/demo_umami/themes/umami/umami.theme \umami_preprocess_field()
Implements hook_preprocess_field().
File
-
core/
profiles/ demo_umami/ themes/ umami/ umami.theme, line 34
Code
function umami_preprocess_field(&$variables, $hook) {
$element = $variables['element'];
// Add class to label and items fields to be styled using the meta styles.
if (isset($element['#field_name'])) {
if ($element['#field_name'] == 'field_recipe_category' || $element['#field_name'] == 'field_tags' || $element['#field_name'] == 'field_difficulty') {
$variables['attributes']['class'][] = 'label-items';
if ($element['#view_mode'] == 'card' && $element['#field_name'] == 'field_difficulty') {
$variables['attributes']['class'][] = 'umami-card__label-items';
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.