You are here

function menu_block_theme_suggestions_menu in Menu Block 8

Implements hook_theme_suggestions_HOOK() for "menu".

File

./menu_block.module, line 79
Provides configurable blocks of menu links.

Code

function menu_block_theme_suggestions_menu(array $variables) {
  $suggestions = [];

  // The MenuBlock plugin's build() method populates this variable.
  if (!empty($variables['menu_block_configuration'])) {
    $config = $variables['menu_block_configuration'];
    $menu_name = strtr($variables['menu_name'], '-', '_');
    $suggestions[] = 'menu__' . $menu_name;

    // Context module (and perhaps others?) adds 'region' into the config.
    if (!empty($config['region'])) {
      $suggestions[] = 'menu__region_' . $config['region'];
      $suggestions[] = 'menu__' . $menu_name . '__region_' . $config['region'];
    }

    // Add our custom theme suggestion.
    if (!empty($config['suggestion']) && $config['suggestion'] !== $menu_name) {
      $suggestions[] = 'menu__' . $config['suggestion'];
    }

    // Context module adds block 'uuid' into the config.
    if (!empty($config['uuid'])) {
      $suggestions[] = 'menu__' . $menu_name . '__' . $config['uuid'];
    }
  }
  return $suggestions;
}