You are here

groupmenu_block.module in Group Menu 8

Adds theme suggestions for group menus.

File

modules/groupmenu_block/groupmenu_block.module
View source
<?php

/**
 * @file
 * Adds theme suggestions for group menus.
 */

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 *
 * Add suggestions for menus in the groupmenus block.
 */
function groupmenu_block_theme_suggestions_menu_alter(array &$suggestions, array $variables) {
  if (isset($variables['attributes']['base_plugin_id']) && $variables['attributes']['base_plugin_id'] == 'groupmenus') {
    $suggestions[] = 'menu__groupmenu';
    if (isset($variables['menu_name'])) {
      $suggestions[] = 'menu__groupmenu__' . strtr($variables['menu_name'], '-', '_');
    }
  }
}

/**
 * Implements template_preprocess_block().
 *
 * Pass block plugin information to menu theme suggestions.
 */
function groupmenu_block_preprocess_block(&$variables) {
  if (isset($variables['elements']['#base_plugin_id']) && $variables['elements']['#base_plugin_id'] == 'groupmenus') {
    $variables['content']['#attributes']['base_plugin_id'] = $variables['elements']['#base_plugin_id'];
  }
}