Reputation: 52
Does anybody know how to add a search block into main-menu block via twig template in Drupal8? enter image description here
I need something like that in main-menu.html.twig:
<div class="wrapper">
<div class="col-md-9"> menu ....</div>
<div class="col-md-3"> Search block should be added there</div>
</div>
Thanks a lot!!!
Upvotes: 1
Views: 2280
Reputation: 52
I've found a solution! We can add a new region in themename.info.yml, like that:
regions:
navigation: 'Navigation'
navigation_collapsible: 'Navigation (Collapsible)'
header: 'Top Bar'
blog_menu: 'Blog menu'
highlighted: 'Highlighted'
help: 'Help'
content: 'Content'
sidebar_first: 'Primary'
sidebar_second: 'Secondary'
footer: 'Footer'
page_top: 'Page top'
page_bottom: 'Page bottom'
And then call this wrapping this region in page.html.twig as needed.
<div class="wrapper">
{{ page.blog_menu }}
</div>
So, both blocks (menu and search) will be added inside new region via admin and wrapped.
Upvotes: 1