NavTool - Documentation topics on: crumbtrail,menus,navigation,navtool,reorder menu,sitemap,site map,.


The $navtool Velocity viewtool allows you to create custom navigations with your own HTML and styles. It builds a navigation structure given a path or folder level, and returns a list of navigation items.


You can use the NavTool through both methods and properties, all of which return an object representing a folder in the dotCMS folder tree.


The getNav() method allows you to access the current folder or to pass in different parameters to access a folder on your site via an absolute path or a relative folder level.

MethodReturn ValueDescription
$navtool.getNav()Nav objectCurrent Folder
Returns the current active navigation folder (the folder where the current page is located).
$navtool.getNav( path )Nav objectAbsolute Path
Returns the children in the specified folder.
$navtool.getNav( level )Nav objectRelative Folder Level
Returns the children of the folder at the specified folder level within the path of the page where the method call is made.

Note: When passing in a level rather than a path, the path will be built from the request URI (e.g. the path as it is displayed in the user's browser) rather than the actual path to the page within dotCMS. For pages which have been accessed via a Vanity URL or URL Map, the request URI is not the actual path of the page being displayed, so an attempt to display the navigation using level will not work. Therefore, to display menus that may be displayed on pages used via Vanity URLs or URL Maps (such as top-level navigation), it is recommended that a path be passed instead of a level.


The getNav() method accepts either a string (a folder path) or an integer (a folder level) as an argument. Both arguments are referenced from the root of the site where the page is located.

pathStringThe folder path to the root of the navigation tree to be displayed.
levelIntegerThe folder level to display within the path to the current page.
0 specifies the root folder of the Site the page is located on, 1 specifies the top-level folder in the current page's path, 2 specifies the next lower level folder in the current page's path, etc.

Method Examples

The following examples describe which folder is returned for different calls to $navtool.getNav() if the method call is made from the “/about-us/locations/index” page on the dotCMS starter site or dotCMS demo site.

MethodReturned Nav Object
$navtool.getNav()The “/about-us/locations” folder (the folder where the page is located).
$navtool.getNav( "/" )The root folder of the site the page is displayed on.
$navtool.getNav( "/application" )The “/application” folder on the site the page is displayed on.
$navtool.getNav( "//" )The “/application” folder on the site.
Note: This only works if is a host on the same dotCMS instance as the page where the code is run.
$navtool.getNav( 0 )The root folder of the site the page is displayed on.
(Equivalent to $navtool.getNav("/").
$navtool.getNav( 1 )The “/about-us” folder.
(Equivalent to $navtool.getNav("/about-us")).
$navtool.getNav( 2 )The “/about-us/locations” folder.
(Equivalent to $navtool.getNav("/about-us/locations")).


If you specify the $navtool object directly, it returns the nav object of the current active folder (where the page is located). This is equivalent to calling $navtool.getNav() (with no arguments).

You may specify the properties of the $navtool object directly (without first having to assign the results to a Velocity variable), and you may chain the properties. This allows you to easily access nav objects for folders relative to the current folder with a single Velocity reference.

Property Examples

The following examples describe which folder is returned for different NavTool property references if the reference is made from the “/about-us/locations/index” page on the dotCMS starter site or dotCMS demo site.

ReferenceReturned Nav Object
$navtoolThe “/about-us/locations” folder (the folder where the page is located).
$navtool.parentThe “/about-us” folder (the parent of the folder where the page is located).
$navtool.parent.parentThe root folder of the site.
$navtool.childrenA list of all siblings of the current page (all objects (files, pages and folders) in the “/about-us/locations” folder).
$navtool.parent.childrenA list of all siblings of the current folder (all objects (files, pages and folders) in the “/about-us” folder).

Return Values

The navtool methods and properties each return a nav object, which contains the following properties:

parentNav objectParent folder.
childrenList of Nav objectsList of children (if the content item is a folder).
titleStringTitle of the content item.
hrefStringURL (href) of the content item.
Clicking this link navigates to the page or file.
orderIntSort Order field of the content item.
activeBooleanTrue if the content item is active.
folderBooleanTrue if the content item is a folder.
typeStringType of content item (“folder”, “htmlpage”, “link”, or “file”).
codeLinkStringCode Link field value (only if the content item is a Menu Link with a Code Link value set).

For example, if you access the nav object using #set($navobj = $navtool.getNav("/")), then you would reference the title parameter as $navobj.title.

Navigation Permissions

By default, the NavTool does not check permissions. This means users will see all navigation items, even if they don't have permission to view those items.

To configure the NavTool to respect permissions, change the ENABLE_NAV_PERMISSION property to true in the file. After this change, only items the current user has permissions to View are returned in the navigation.



  • It is strongly recommended that any changes to the file be made through a configuration file extension.
  • If the ENABLE_NAV_PERMISSION_CHECK property is enabled, it is recommend that you enclose the navigation in a #dotcache block to avoid performance degradation.


The following examples demonstrate several different ways to use the navigation tool to display navigation objects and customize navigation.

Example: Get the Current Active Navigation Folder

You can get the current active navigation folder by calling navtool.getNav() without any arguments.

#set($nav = $navtool.getNav())

Example: Two level Navigation

This example displays the navigation from the root of the folder tree, highlighting the active folder with the <strong> tag (if close enough to the root folder to be displayed in the navigation). The dotCMS documentation site left-side navigation bar uses a method similar to this to display the documentation tree.

#set( $list = $navtool.getNav("/") )
  #foreach($n in $list)
      <a href='${n.href}'>${n.title}</a>
      #set($children = $n.children)
      #if( $children && $children.size() > 0 )
          #foreach($child in $children)
              #if($<strong>#end <a href='${child.href}'>${child.title}</a> #if($</strong>#end
              #set($grandchildren = $child.children)
              #if( $grandchildren && $grandchildren.size() > 0 )
                  #foreach($grandchild in $grandchildren)
                    <li>#if($<strong>#end <a href='${grandchild.href}'>${grandchild.title}</a> #if($</strong>#end

Example: Display the Navigation for the Parent Folder

This example works almost exactly the same as the previous example, but instead of displaying the navigation from the root of the folder tree, this example displays the navigation from 1 level up from the current folder (the parent folder), displaying both the current folder's siblings and children. As with the previous example, the active folder will be highlighted with the <strong> tag.

#set( $list = $navtool.getNav(1) )
  #foreach($n in $list)
      <a href='${n.href}'>${n.title}</a>
      #set($siblings = $n.children)
      #if( $siblings && $siblings.size() > 0 )
          #foreach($sib in $siblings)
              #if($<strong>#end <a href='${sib.href}'>${sib.title}</a> #if($</strong>#end
              #set($children = $sib.children)
              #if( $children && $children.size() > 0 )
                  #foreach($child in $children)
                    <li><a href='${child.href}'>${child.title}</a>

Example: Add a “Reorder” button in Edit Mode

The following code adds a re-order button to the custom navigation when the page is viewed in Edit mode. For a more complete example using this method, see the Custom Navigation example, below.


      <form class="navbar-form navbar-right" action="${directorURL}" method="post" target="_parent" name="${_formId}" id="${_formId}">
        <input type="hidden" name="cmd" value="orderMenu" />
        <input type="hidden" name="hostId" value="${host.identifier}" />
        <input type="hidden" name="referer" value="${VTLSERVLET_URI}" />
        <input type="hidden" name="pagePath" value="${VTLSERVLET_URI}" />
        <input type="hidden" name="startLevel" value="1" />
        <input type="hidden" name="depth" value="2" />
        <a href="javascript:document.getElementById('${_formId}').submit();" class="btn btn-primary btn-xs normaltip" data-original-title="Reorder Menu">
            <i class="fa fa-arrow-up"></i> 
            <i class="fa fa-arrow-down"></i> 


Example: Build a Crumbtrail

The following code builds a crumbtrail up to 25 levels deep (based on the Show on Menu settings on the pages, files and folders in your site).

## Get the Nav item for the current folder
#set($current = $navtool.getNav())

## Build the list of folders to display in the crumbtrail
#set($crumb = $contents.getEmptyList())
#foreach($item in [1..25])
     #set($current = $current.parent)
     #if($current.title=="System folder")

## Display the crumbtrail
     <li style="display:inline"><a href="/">Home</a></li>
     #foreach($item in $crumb)
          <li style="display:inline">     
               <a href="$item.href">$item.title</a>

Toolbox.xml Configuration

The NavTool is enabled by default in dotCMS. To ensure the NavTool is enabled, verify that the following lines exist in your toolbox.xml file:



For complete documentation on this viewtool, please see the following documentation: