(Quick Reference)

nav:menu

Purpose

Renders a <ul> menu structure for a scope within your navigation structure.

The menu tag is used internally by the primary/secondary tags and can be called directly to render any scope in the navigation structure, with any activation path.

Example

{docx:xml} <nav:menu/>

<nav:menu id="main-nav"/>

<% Render the admin nav 3-deep, including all nested descendents whether active or not %> <nav:menu scope="admin" depth="3" forceChildren="true"/>

<% Custom item rendering > <nav:menu id="nav" custom="true"> <li class="${item.data.icon ? 'i_'+item.data.icon : ''}"> <p:callTag tag="g:link" attrs="${linkArgs + class:active ? 'active' : ''}"> <span> <nav:title item="${item}"/> </span> </p:callTag> <g:if test="${active && item.children}"> <nav:menu scope="${item.id}" custom="true" class="visible"> <li class="${item.data.icon ? 'i_'+item.data.icon : ''}"> <p:callTag tag="g:link" attrs="${linkArgs + class:active ? 'active' : ''}"> <span> <nav:title item="${item}"/> </span> </p:callTag> </nav:menu> </g:if> </li> </nav:menu> {docx}

Note that with custom rendering the body is responsible for rendering any nested children also.

Attributes

NamePurpose
pathOptional activation path to use. If not supplied, will use the current request's activation path which may have been set manually with setActivePath:navigationTags tag or by reverse-looking up the current controller and action
scopeOptional scope to render. If supplied, a string of the form rootScopeName/scopeA/scopeB is expect and should resolve to a navigation item. The children of that item will be rendered as the top level menu items. If not supplied, will default to the scope indicated by the activation path being used, and if that does not resolve to anything, it defaults to "app"
classOptional CSS class to apply to the outer <ul> tag. Defaults to "nav"
idOptional id attribute to apply to the outer <ul> tag. Defaults to no value
depthOptional depth of navigation to render. Starting from the scope, it will iterated down one level by default. It will render nested <ul> if depth is greater than 1. By default it will only render children if the parent is on the activation path
forceChildrenOptional Boolean indicating whether or not to render all nested children even if the parent is not active
customOptional Boolean indicating that you want to handle rendering of the <li> items directly. The body of the menu tag is used to render each item, and the body is passed the values item (the NavigationItem instance), linkArgs the map of arguments to pass to g:link to create a link to the target of the item, as well as active and enabled booleans for the item.