NavigationWebAPI Tool - Documentation topics on: deprecated,navigationwebapi,.

NavigationWebAPI Tool
Deprecated

The NavigationWebApi Tool ($nav) Velocity viewtool provides methods to help you build and manage custom navigation such as custom menus and crumbtrails. This viewtool provides in-depth access to dotCMS navigation methods beyond the basic methods provided by the NavTool.

Methods

The NavigationWebApi Tool supports the following methods:

MethodReturn TypeDescription
$nav.buildMenuItems(startFromPath, numberOfLevels, request)StringReturns the path of a file which contains menu items created and ordered based on the specified startFromPath and numberOfLevels.
$nav.createMenu(startFromPath, numberOfLevels, request)StringReturns an HTML string containing a navigation menu (complete with titles and links) built from the specified startFromPath and numberOfLevels.
$nav.createMenuByDepth(startFromLevel, maxDepth, request)StringReturns an HTML string containing a navigation menu (complete with titles and links) built from the specified startFromPath and maxDepth.
$nav.createSiteMapMenu(startFromLevel, numberOfLevels, request)StringDeprecated. Use alternate calling conventions (below) instead.
$nav.createSiteMapMenu(startFromLevel, numberOfLevels, path, request, addHome)StringReturns the path to a file containing a linked HTML site map (in nested unordered list format).
$nav.createSiteMapMenu(startFromLevel, numberOfLevels, path, request, addHome, reverseOrder)StringReturns the path to a file containing a linked HTML site map (in nested unordered list format).
$nav.crumbTrail(request, imgPath)StringReturns an HTML string containing a crumbtrail (complete with titles and links) built from the specified imgPath.
$nav.crumbTrail(request, imgPath, homePath)StringReturns an HTML string containing a crumbtrail (complete with titles and links) built from the specified homePath / imgPath.
$nav.crumbTrail(request, imgPath, homePath, crumbTitle)StringReturns an HTML string containing a crumbtrail (complete with titles and links) built from the specified homePath / imgPath and crumbTitle.
$nav.getFormCount()IntegerGets the value of the internal formCount variable, which can be used to keep track of navigation menu building.
$nav.getPagesList(folderPath, request)List of Page objectsReturns a list of Page objects for pages contained in the specified folderPath.
$nav.getStartFromPath(startFromLevel, request)StringReturns the path that will be used if the startFromLevel is set to the specified value.
$nav.increaseFormCount()None (void)Adds 1 to the value of the internal formCount variable, which can be used to keep track of navigation menu building.
$nav.menuItems(startFromPath, numberOfLevels, request)BooleanReturns true if the menu specified by the startFromPath and numberOfLevels is valid and contains items in it.
$nav.menuItemsByDepth(startFromLevel, maxDepth, request)BooleanReturns the number of menu items found by starting from the specified startFromLevel and traversing the tree to the specified maxDepth.

Parameters

ParameterDefaultDescription
addHomeBooleanIf true, include the “Home” page of the specified path in the list; otherwise only its children will be included.
crumbTitleStringTitle for the crumb trail.
folderPathStringPath to a specific folder in the folder tree.
homePathStringPath to the home folder of the navigation.
imgPathStringPath to the folder of the navigation.
maxDepthIntegerMaximum depth to traverse the folder tree.
0 = current folder only, 1 = current folder and children, 2 = current folder and grandchildren, etc.
numberOfLevelsIntegerNumber of levels to traverse the folder tree.
pathStringPath of the folder to begin navigation.
requestRequest objectThe dotCMS $request object.
reverseOrderBooleanReverse the order in which the links are included in the list.
startFromLevelIntegerNavigation level to start from, relative to the current folder.
0 = the current folder, 1 = the parent folder, 2 = the grandparent folder, etc.
startFromPathStringFolder path to start the search for menu items from.

Examples

Example: Add a “Reorder Menu” Button in Edit Mode

The NavTool documentation contains an example which uses the NavigationWebApi Tool getStartFromPath(), getFormCount(), and increaseFormCount() methods to add a Reorder Menu button to the navigation on the page when a user views the page in Edit mode.

Toolbox.xml Configuration

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

<tool>
    <key>nav</key>
    <scope>request</scope>
    <class>com.dotmarketing.viewtools.NavigationWebAPI</class>
</tool>

References

For more information on this viewtool, please see the following documentation in the dotCMS Javadocs: