Category Mega Menu
Display a category mega menu which allows users to see your sub-categories in a large menu.
Wireframe
Preparation Checklist
Before you start this tweak, it's a good idea to run through our preparation checklist below:
- Read through the Getting Started to get a better sense of how the control panel, Database and Front End store interact.
- Learn our recommended Simple Workflow. This makes the implementation process as easy as possible.
- Create a new Staging Theme for this tweak. This allows you to preview any changes before they are visible to live customers.
- The code snippet in this tweak doc uses Bootstrap 4, you may need to alter this code depending on what version of Bootstrap your theme is using. You can find out what version your theme is using here.
Coding Instructions
Step 1: Open the header template
The header template can be found here /httpdocs/assets/themes/[THEME-NAME]/templates/headers/template.html
.
Step 2: Add the code into the template
Paste the following code into the header template replacing the existing ul
menu section highlighted here.
[%cache type:'cmenu' id:'header_category_menu'%]
[%content_menu content_type:'category' sortby:'sortorder,name' show_empty:'1'%]
[%param *header%]
<ul class="navbar-nav mr-auto" role="navigation" aria-label="Main menu">
[%/param%]
[%param *level_1%]
<li class="nav-item dropdown position-static">
<a href="[@url@]" [%if [@next_level@]%] class="nav-link dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" [%else%] class="nav-link" [%/if%]>[@name@]</a>
[%if [@next_level@]%]
<ul class="dropdown-menu mega-menu w-100 p-lg-3">[@next_level@]</ul>
[%/if%]
</li>
[%/param%]
[%param *level_2%]
<li class="nav-item d-inline-block w-100">
<a href="[@url@]" class="nav-link font-weight-bold">[@name@]</a>
[%if [@next_level@]%]
<ul>[@next_level@]</ul>
[%/if%]
</li>
[%/param%]
[%param *level_3%]
<li class="nav-item">
<a href="[@url@]" class="nav-link py-1">[@name@]</a>
</li>
[%/param%]
[%param *footer%]
</ul>
[%/param%]
[%/content_menu%]
[%/cache%]
Step 3: Add styling
Navigate to the stylesheet /httpdocs/assets/themes/[THEME-NAME]/css/style.css
and paste the following code:
@media (min-width: 768px) {
.mega-menu {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
}
}
@media (min-width: 1200px) {
.mega-menu {
-webkit-column-count: 4;
-moz-column-count: 4;
column-count: 4;
}
}
Final Result
Customising this section
More information on how to customise this section can be found within the Content Menu Documentation.