HomeНаука и техникаRelated VideosMore From: Drupal Legoland

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

23 ratings | 4586 views
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: https://www.drupal.org/project/menu_block Menu Block Documentation: https://www.drupal.org/node/1934824 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 Debug: 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 `````````````````````````````````````````````````````````````````````` STEPS (For DRUPAL 8): `````````````````````````````````````````````````````````````````````` - 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! Note: -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"
Html code for embedding videos on your blog
Text Comments (30)
Mark Chambers (2 months ago)
Wow, it's a lot easier in Drupal 8, isn't it? Thanks for taking the time to explain this!
Jirka Stránský (7 months ago)
Hi, the video tutorial is great and thank you for it. I would like to ask whether it is possible to activate the color buttons on Drupal 8, as in the video when turning on the modules. Thank you
erratic_calm (1 year ago)
Thank you so much for this. You just helped me solve a very frustrating problem. I like the default Drupal behavior much better for my needs. :)
Drupal Legoland (1 year ago)
Great it helps ! Keep it up !
Ben Pridmore (1 year ago)
Hi, great tutorial! I'm trying to only show the sub menu items of an active trail and to hide all other sub menus. Without doing this my menu will be huge. Thanks mate.
Drupal Legoland (1 year ago)
Great ! Thanks for sharing ! Happy drupaling !
Ben Pridmore (1 year ago)
Hi, This css worked: // hide all children .menu-block-wrapper li.expanded ul.menu { display:none; } // unhide children of active parent .menu-block-wrapper .expanded.active-trail.active .menu { display:block; } Thanks for the videos!
Drupal Legoland (1 year ago)
Glad it helps! Yes, without overriding the menu you will have a lot more to do with CSS though it works too. Happy drupaling !
Lamar Brantley (1 year ago)
Thanks so much for all the tuts! I just went through all 35 in the past 2 days as a refresher for a large Bootstrap based extranet I am developing for a client. Do you have an opinion of Panelizer vs Display Suite?
Drupal Legoland (1 year ago)
Glad to hear that ! Both are great to customize your content layout. Panelizer seems to provide more controls over the layout with access and context. DS is simpler and I enjoy using it most especially when working on a bootstrap theme. DS's layout is clean and easy to customize the way you need. Whenever using DS, I will use "Context" module as well for some conditions and reactions that DS lacks of. However, it's good to explore Panelizer yourself, build the same layout and see the difference. For a more complicated website and complex layout design like news portal, Panels + Panelizer is likely a great help! Share with us if you come across any interesting findings in your project between these two great modules. Happy drupaling!
Jeb Bush (1 year ago)
Is this Drupal 7 or 8?
Drupal Legoland (1 year ago)
This video is for Drupal 7. For D8 please see description area above in text.
korosh farzadi (1 year ago)
tanks very mice
Mindaugas Rudz (1 year ago)
Just perfect! One more great drupal video! why don't you have your own website? Honestly I would pay you if you would have full online class. Is there any way to contact you for some help (not for free) 'cause for me Drupal is like programming language, you know the tools but most often don't know how to use them correctly to achieve what you want. And it is hard to find answers online. Anyway, waiting for new videos!
Drupal Legoland (1 year ago)
You are most welcome ! Thanks for your feedback and supports again ! Sure, will continue to share my passion and love my drupal. You too, hope to learn from you one day, keep it up and all the best ! Guru !
Mindaugas Rudz (1 year ago)
thanks for the answers around all your videos! build a simple website, register your Patreon, and help subscribers to solve their problem during your free time :) . That would work for everyone :) best luck! MR
Drupal Legoland (1 year ago)
Thanks for your kind words ! Glad you find the tutorials here helpful! Building a personal website ? Good suggestion ! Meanwhile I'm on a long break, not taking any project at this time. However, feel free to post it on the relevant video and I will help what I can though it may not a quick reply as you will expect. If you are working on a project which require prompt reply and intensive supports, you may approach great site like OSTraining for some helps. Drupal on Stack Exchange is also a great site to look for supports. Often you will be surprised by their prompt replies and insights. http://drupal.stackexchange.com I know it's not easy to pick up Drupal in the beginning, but once you are familiar on how some modules work, you can always work it out yourself to build a site you need especially with Views without much coding. With Views module, you can pull out the data you need and structure the way you like as you have learnt by now, you won't get such a powerful building tool in any other CMS at this time! Above all, it's all free! Thanks for your support again and keep it up !
Просто Влад (1 year ago)
Thank you very much for this videos! They're very helpful. Most concise and clear information about drupal bootstrap theme around youtube.
Drupal Legoland (1 year ago)
Thanks for your kind words and I'm glad you find it helpful! Keep it up !
Yunus Akyol (1 year ago)
another great video mate ! you are the best. Can you make a video for google map module and animated sidebar menu please ?
Drupal Legoland (1 year ago)
Great ! For accordion menu you can try "Accordion Menu" module. If you know a bit of jquery, you can write your own script to animate the menu too. Same to you and have a great day ! https://www.drupal.org/project/accordion_menu
Yunus Akyol (1 year ago)
Thanks for your helps Drupal Legoland ! i tried gmap and it works <3 and for "animated sidebar menu" i mean accordion menu. Thanks and Have a good day !
Drupal Legoland (1 year ago)
Thanks ! For google map module I think there are quite a number of videos already explained well. "Geolocation Field" module is a nice one and able to show result for multiple locations within a single map via Views. It has stable release on both Drupal 7 and Drupal 8. Worth trying out. Geolocation Field https://www.drupal.org/project/geolocation Video by WDTutorials: https://www.youtube.com/watch?v=OIctqoV6zoI "GMap" module is another great and popular module too. There are quite a number of tutorials you can find on the internet. Just do a quick search. Below just to name a few. OSTraining: https://www.ostraining.com/blog/drupal/gmap Webwash: https://goo.gl/MWs7Hr --------------------- As for "animated sidebar menu", could you please clarify a bit more, you mean accordion menu ? We usually leave the sidebar menu as it is, leave it expanded or make it an accordion menu. Whereas the top main navigation menu you can have more to play with. Check it out on "Responsive Menus" module https://www.drupal.org/project/responsive_menus Keep it up !
Khaled Nabilsi (1 year ago)
hey, can you give us a full tutorial creating an entire web site in drupal with bootstrap please?
Drupal Legoland (1 year ago)
I see. Added to the wishlist ! Keep it up !
Khaled Nabilsi (1 year ago)
Drupal Legoland 2017 drupal 8 please
Drupal Legoland (1 year ago)
Have you noticed this is already a full series of creating Bootstrap website with Drupal. No ? https://goo.gl/WxZNuw
Ouedraogo Naabiga (1 year ago)
That video is very good! If you could do some Drupal PHP videos' that's be helpful too. Thank you for all.
Ang 78 (1 year ago)
I am going to try this for Drupal 8 😁
Drupal Legoland (1 year ago)
Great ! But for Drupal 8 is a bit different. I have added some steps in the description area for Drupal 8, you can try and see if it works. If you know any better way of doing it in D8, share with us! Keep it up !

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.