function uikit_theme_suggestions_block_alter

8.x-3.x alter.inc uikit_theme_suggestions_block_alter(array &$suggestions, array $variables)
8.x-2.x alter.inc uikit_theme_suggestions_block_alter(array &$suggestions, array $variables)

Implements hook_theme_suggestions_HOOK_alter() for block templates.

File

includes/alter.inc, line 42
Modify structured content arrays.

Code

function uikit_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  $base_plugin_id = $variables ['elements']['#base_plugin_id'];
  $id = $variables ['elements']['#id'];
  $block = Block::load($id);
  $region = $block->get('region');

  // Add block__REGION to theme suggestions.
  $suggestions [] = 'block__' . $region;

  // Add block__REGION__menu to system menu blocks and block__navbar__item to
  // non-system menu and non-system branding blocks.
  $system_branding_block = $base_plugin_id == 'system_branding_block';
  $system_menu_block = $base_plugin_id == 'system_menu_block';
  if ($system_menu_block) {
    $suggestions [] = 'block__' . $region . '__menu';
  }
  elseif ($region == 'navbar' && !$system_branding_block) {
    $suggestions [] = 'block__navbar__item';
  }
}

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Log in