dotCMS - Open Source Content Management System, Ondemand CMS, and Professional Support

Document Search

Article Information

Since Version: 1.6.5
Tags: Navigation Menu Builder macros
Updated: 11/19/2008 5:57:47 PM
By: Dean Gonzalez
Doc id: 151445
Print Page: Export to PDF
 

Related Screencasts

Video Tutorial - Using the Menu Macro in dotCMS
Learn step–by–step how to create a dynamic menu using the dotCMS menu macro.

Navigation Menu Builder

This macro will build a navigational menu using unordered lists sutiable for standard top or left-hand navigation. These lists can then be formated by css. The resulting code will look like (where the 2nd <li> is the active link).

Macro Overview:

Syntax:

#navigation('startLevel' 'levelsToShow')

Arguments:

  • startLevel
    This is navigational level to start the menu on.
  • levelsToShow
    This is how deep you would like the generated menu to be.

Optional Parameters:

  • menuSpans
    If the $menuSpans variable is set to true before the macro is called, then tags will be added around each menu link, like:
    <li><a href="/path/to/pageOrFolder"><span>Menu item 1</span></a></li>
  • openAllLevels
    If this variable is set all menu items will be displayed on the navigation with no regard to where the user is on the site. This is very useful for top navigation drop downs that need to show all links.

Usage:


Examples:

Example 1: A simple example using the required fields

#navigation(2,2)

This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection.

Example 2: An example showing how to include one or more of the optional parameters

#set($openAllLevels=true)
#navigation(2,2)

This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection.

Example 3: An example showing how to include one or more of the optional parameters

<div id="leftNav">
#set($menuSpans = true)
#navigation(2,2)
</div>

This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection. It will also add span tags around all links.

Example 4: An example showing how to include one or more of the optional parameters

<div id="leftNav">
#set($openAllLevels=true)
#navigation(2,2)
</div>

This would build a navigation bar 2 levels deep, which would open as the user clicked into a subsection.

Example 5: An example showing how to include one or more of the optional parameters

<div id="leftNav">
#set ($navigationSourceCode = '/my_velocity_files/my_navigation.vtl')
#navigation(2,2)
</div>

This would build a navigation with your own source code.



Post a Comment


Add Comments

   

 
Post