function uikit_preprocess_block

8.x-3.x preprocess.inc uikit_preprocess_block(&$variables)
8.x-2.x preprocess.inc uikit_preprocess_block(&$variables)
7.x-3.x preprocess.inc uikit_preprocess_block(&$variables)
7.x-2.x preprocess.inc uikit_preprocess_block(&$variables)

File

includes/preprocess.inc, line 156
Set up variables to be placed within the template (.html.twig) files.

Code

function uikit_preprocess_block(&$variables) {
  // Provide an id attribute to help themers.
  $id = $variables ['elements']['#id'];
  $id = Html::cleanCssIdentifier($id);
  $variables ['attributes']['id'] = $id;

  $base_plugin_id = $variables ['base_plugin_id'];
  $system_menu_block = $base_plugin_id == 'system_menu_block';
  $block = Block::load($variables ['elements']['#id']);
  $region = $block->getRegion();

  switch ($region) {
    case 'navbar':
      if ($system_menu_block) {
        // Define #theme variable for navbar menus.
        $variables ['content']['#theme'] = 'menu__navbar';
      }
      break;

    case 'offcanvas':
      if ($system_menu_block) {
        // Define #theme variable for offcanvas menus.
        $variables ['content']['#theme'] = 'menu__offcanvas';
      }
      break;
  }
}

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