简体   繁体   中英

How to add a secondary menu to Bolt CMS?

The default way to add a menu to a template::

{{ menu(identifier = 'footer',
        template = 'partials/_sub_menu.twig',
        params = {'withsubmenus': false, 'class': 'inline-list align-right'}**strong text**
) }}

But how to build a secondary menu from other files than menu.yml ?

To add a secondary menu go to menu.yml add for the mentioned example this lines of code:

footer:
    - label: Imprint
      title: Go to Imprint
      path: page/imprint
      class: first

The documentation can be found here: https://docs.bolt.cm/3.0/content/menus

Further explanation:

  1. All menus used have to be declared in menu.yml .

  2. To render them correctly you can call them in two different ways.

Example #1:

{{ menu(identifier = 'footer', template = 'partials/_sub_menu.twig') }}

Example #2 (Short hand syntax):

{{ menu(footer', 'partials/_sub_menu.twig') }}

Note: You can define more than one menu in your menu.yml file, but you should define only one menu in each template file. So, if you have multiple menus that should be rendered with different HTML, you should have as many _menu_menuname.twig files in your theme.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM