Skip to content

Menu system

Filip Hnízdo edited this page Sep 8, 2016 · 4 revisions

Menus are lists of links and sublinks that can be used for navigating through your site.

To create a menu, go to the menu interface in the structure section of the administration toolbar.

Hit edit next to an existing menu or create a new one by selecting the create new menu button.

Embedding menus in a theme

To embed a menu in the theme either use a menu block if the menu block module is enabled or use a menu embed template in an HTML template. An optional template parameter can override the menu template.

{{{iris embed='menu' menu="admin_toolbar"}}}

Theming menus

The default menu.html template can be found in the menu module's template folder. iris_core/modules/core/menu/templates/menu.html

This can be overridden by a theme or module (for more information look at the template naming and lookup documentation).

The menu template lookup also takes an additional parameter of the menu name so you can create a template for a specific menu using menu_menuname.html

Registering and populating a menu in code for a custom route

When defining a custom Express route in code using iris.route you can add it to a menu by passing through a menu object to the route's options. See routing system documentation for more information.

The only required parameter is menuName for the name of the menu (registered automatically as soon as a link is created for it). It makes sense to also include a title for where the menu is displayed. parent is used for when the menu item is a child of another item in the menu. Write in the path of this parent. An optional path parameter will let you use a custom path for the menu (it defaults to the path of the route).

As an example:

iris.route.get("/admin/structure", {
  "menu": [{
    menuName: "admin_toolbar",
    parent: "/admin",
    title: "Structure"
  }]
}, function (req, res) {

  // Logic for your route

});
Clone this wiki locally