Drupal Bootstrap - 35 - BONUS: Disable Dropdown Support For Sidebar Menu

In this tutorial we are going to add a menu to the left sidebar without the dropdown function which Bootstrap theme has overridden for all menus. To do this, we will install the Menu block module, override and restore the original theme_menu_link() function for Menu Block module. 

Playlist: https://goo.gl/yiadTa

Module to install:

Menu Block Documentation:

Theme functions to be overridden:

  • [theme]_menu_link__menu_block()

STEPS (Drupal 7):
Step 1: Install and enable the Menu Block module 
Step 2: Add a menu block to the primary region
Step 3: Copy original theme_menu_link() function from includes\menu.inc file and paste it to the template.php file located at your sub theme folder. e.g sites\all\themes\bootstrap_subtheme\template.php
Step 4: Update the function name with your sub theme name and apply to menu block. e.g.
bootstrap_subtheme_menu_link__menu_block(). For good practice, you can add a comment to the function. 
Step 5: Flush all caches

1. Make sure you replace the [theme] name with your sub theme name correctly. Earlier we created a sub theme called "bootstrap subtheme" and hence the function name should be bootstrap_subtheme_menu_link__menu_block()

2. Make sure you flush all caches



  • Install and enable the Menu Block module 
  • Go to Block layout (Structure -} Block Layout), place a "Main navigation" block under "Primary" region
  • Under "HTML AND STYLE OPTIONS" - "Theme hook suggestion", replace "main" with "menu_block" (though you can rename any name you like) and save blocks
  • Go to \core\modules\system\templates\menu.html.twig and copy this file.
  • Go to your sub theme and paste the file inside \templates folder.  E.g themes\your_theme_name\templates\menu.html.twig. 
  •  rename this twig file "menu" to "menu--menu_block" (Take note of the two Dashes and Underscore). E.g themes\your_theme_name\templates\menu--menu_block.html.twig
  • Flush caches and done!


  • Basically what happen here is you create a new theme hook suggestion and override the menu.html.twig for menu block you created. 
  • You can reuse the same theme hook suggestion - "menu_block" as many as you like for other menu blocks you created. They will all pick up from the same "menu--menu_block.html.twig"