Category Menu

A standard category menu, displaying the sub-categories on click.

Wireframe

Category Menu


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="Category menu">
    [%/param%]
    [%param *level_1%]
        <li class="nav-item [%if [@next_level@]%] dropdown [%/if%]">
            <a href="[@url@]" class="nav-link [%if [@next_level@]%] dropdown-toggle[%/if%]" [%if [@next_level@]%]role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"[%/if%]>[@name@]</a>
            [%if [@next_level@]%]
                <ul class="dropdown-menu">
                    [@next_level@]
                </ul>
            [%/if%]
        </li>
        [%/param%]
    [%param *level_2%]
        <li class="[%if [@next_level@]%] dropdown dropdown-hover [%/if%]">
            <a href="[@url@]" class="nuhover dropdown-item">[@name@]</a>
            [%if [@next_level@]%]
                <ul class="dropdown-menu dropdown-menu-horizontal">
                    [@next_level@]
                </ul>
            [%/if%]
        </li>
        [%/param%]
    [%param *level_3%]
        <li>
            <a href="[@url@]" class="dropdown-item pl-5 pl-md-4">[@name@]</a>
        </li>
    [%/param%]
    [%param *footer%]
        </ul>
    [%/param%]
[%/content_menu%]
[%/cache%]

Customising this section

More information on how to customise this section can be found within the Content Menu Documentation.

Was this article useful?

Be notified when this page is updated. Optional.