diff --git a/bootstrap_barrio.theme b/bootstrap_barrio.theme index ac7effa15528e1007c8eb5b2d9aa98a1097328b6..61d6bb2ed3fa49cf229e08fa950fb3ccd1f9f961 100644 --- a/bootstrap_barrio.theme +++ b/bootstrap_barrio.theme @@ -348,6 +348,7 @@ function bootstrap_barrio_preprocess_region(&$variables) { * Implements hook_preprocess_HOOK() for block.html.twig. */ function bootstrap_barrio_preprocess_block(&$variables) { + $variables['content']['#attributes']['block'] = $variables['attributes']['id']; // Add a clearfix class to system branding blocks. if ($variables['plugin_id'] == 'system_branding_block') { $variables['attributes']['class'][] = 'clearfix'; @@ -420,6 +421,18 @@ function bootstrap_barrio_preprocess_menu_local_task(&$variables) { $variables['item'] = Link::fromTextAndUrl($link['title'], $url); } +/** + * Implements hook_theme_suggestions_HOOK_alter(). + */ +function bootstrap_barrio_theme_suggestions_menu_alter(array &$suggestions, array $variables) { + // Taken from http://kristiankaa.dk/article/drupal8-region-specific-menu-theme-hook-suggestion + // bootstrap_barrio_preprocess_block(&$variables) + if (isset($variables['attributes']['block'])) { + $hook = str_replace(array('block-', '-'), array('', '_'), $variables['attributes']['block']); + $suggestions[] = $variables['theme_hook_original'] . '__' . $hook; + } +} + /** * Implements hook_preprocess_HOOK() for menu-local-action.html.twig. */