stk:navigation.create-menu(template)

Renders a standard ol-li menutree.

element()stk:navigation.create-menu
  1. element()*menuitems
  2. xs:integerlevels
  3. xs:integercurrent-level
  4. xs:string?class
  5. xs:string?id
  6. xs:string?container-element
  7. xs:string*attr

Examples

Menu, one level

Input

<xsl:call-template name="stk:navigation.create-menu">
    <xsl:with-param name="menuitems" select="/result/menus/menu/menuitems"/>
    <xsl:with-param name="levels" select="1"/>
</xsl:call-template>

Result

<nav role="navigation">
  <ol role="menu" class="menu-level-1">
    <li role="menuitem">
      <a href="https://enonic.com/stk/home">Home</a>
    </li>
    <li role="menuitem" class="parent">
      <a href="https://enonic.com/stk/template-reference">Template reference</a>
    </li>
    <li role="menuitem">
      <a href="https://enonic.com/stk/articles">Articles</a>
    </li>
  </ol>
</nav>

Menu, multiple levels

Input

<xsl:call-template name="stk:navigation.create-menu">
    <xsl:with-param name="menuitems" select="/result/menus/menu/menuitems"/>
    <xsl:with-param name="levels" select="2"/>
</xsl:call-template>

Result

<nav role="navigation">
  <ol role="menu" class="menu-level-1">
    <li role="menuitem">
      <a href="https://enonic.com/stk/home">Home</a>
    </li>
    <li role="menuitem" class="parent">
      <a href="https://enonic.com/stk/template-reference">Template reference</a>
      <ol role="menu" class="menu-level-2">
        <li role="menuitem" class="parent">
          <a href="https://enonic.com/stk/template-reference/xslt">XSLT</a>
        </li>
        <li role="menuitem" class="parent">
          <a href="https://enonic.com/stk/template-reference/js">JS</a>
        </li>
      </ol>
    </li>
    <li role="menuitem">
      <a href="https://enonic.com/stk/articles">Articles</a>
    </li>
  </ol>
</nav>

Parameters

menuitems
The menuitem(s) used for the menu tree. Accepts both "menuitems" and "menuitem" elements from the result XML
Type
element()*
levels
The number of menu levels to return
Type
xs:integer
Default
99
current-level
The start level (only used for styling)
Type
xs:integer
Default
1
class
One or more classes to add to the list element
Type
xs:string?
id
ID to add to the list element
Type
xs:string?
container-element
An HTML container element for the menu
Type
xs:string?
Default
nav
attr
Custom attributes. Format: 'foo=bar'. Multiple attributes: 'foo=bar', 'fish=salmon'
Type
xs:string*