dspPrimaryNav - Mura Docs v7.0

dspPrimaryNav

A Mura Scope helper method to dynamically output primary navigation. Mura also checks a user's permissions, and will only display links to content the user has access to. If a section of a site is restricted, a link will be generated to the topmost content item only. If a user visits that link, they will be presented with a login screen, if they're not currently logged in, or if they are logged in and don't have access, a message will inform the user they do not have the proper authorization.

Function Syntax

m.dspPrimaryNav(
viewDepth
, id
, class
, displayHome
, closeFolders
, openFolders
, showCurrentChildrenOnly
, liClass
, liHasKidsClass
, liHasKidsAttributes
, liCurrentClass
, liCurrentAttributes
, liHasKidsNestedClass
, aHasKidsClass
, aHasKidsAttributes
, aCurrentClass
, aCurrentAttributes
, ulNestedClass
, ulNestedAttributes
, aNotCurrentClass
, siteid
, complete
)

Parameters

Parameter Type Req/Opt Default Description
viewDepth Numeric Opt 1

Expects a numeric value to indicate how 'deep' each top level nav should go when listing its children. It is not recommended to set this greater than 1 or 2 due to the overhead required to parse a node's 'current' location and permissions. Setting it to a '0' results in no dropdowns or more specifically, no output of links to child nodes.

id String Opt navPrimary

This is the id attribute of the opening <ul> element used to output primary navigation.

class String Opt  

This is the class attribute of the opening <ul> element used to output primary navigation.

displayHome String Opt conditional

This controls whether or not a 'Home' link appears in the primary navigation. Valid options are:

  • conditional - does not display a link to 'Home' when viewing the Home page itself, but will display at all other times
  • always - a link to 'Home' will appear at all times
  • never - a link to 'Home' will never appear
closeFolders string Opt  

This controls the visibility of a Folder's child links. Valid options are:

  • true
  • false
  • A comma-delimited list of ContentID's (found on the 'advanced' tab of any content item).
openFolders string Opt  

This controls the visibility of a Folder's child links. Valid options are:

  • true
  • false
  • A comma-delimited list of ContentID's (found on the 'advanced' tab of any content item).
showCurrentChildrenOnly boolean Opt false

This controls the visibility of a content item's child links. If true, then child links will only appear for the section currently being viewed on the front end of the site. This can be useful when creating a vertical oriented navigation. Valid options are:

  • true
  • false
liClass string Opt  

Controls the class attribute of <li> elements.

liHasKidsClass string Opt  

Controls the class attribute of <li> elements that have children.

liHasKidsAttributes string Opt  

Optionally pass in any additional attributes to output with <li> elements that have children.

liCurrentClass string Opt  

Control the class attribute of the current <li> element.

Also configurable via the Site or Theme contentRenderer.cfc's this.liCurrentClass setting.

liCurrentAttributes string Opt  

Optionally pass in any additional attributes to output with the current <li> element.

liHasKidsNestedClass string Opt  

Control the class attribute of any <li> element that has children. Useful for adding markup that will include icons such as arrows, etc.

Also configurable via the Site or Theme contentRenderer.cfc's this.liHasKidsNestedClass setting.

aHasKidsClass string Opt  

Control the class attribute of <a> elements that have children.

aHasKidsAttributes string Opt  

Optionally pass in any additional attributes to output with <a> elements that have children.

aCurrentClass string Opt current

Control the class attribute of the current <a> element.

Also configurable via the Site or Theme contentRenderer.cfc's this.aCurrentClass setting.

aCurrentAttributes string Opt  

Optionally pass in any additional attributes to output with the current <a> element.

Also configurable via the Site or Theme contentRenderer.cfc's this.aCurrentAttributes setting.

ulNestedClass string Opt  

Control the class attribute of <ul> elements that are nested within other <ul> elements.

ulNestedAttributes string Opt  

Optionally pass in any additional attributes to output with <ul> elements that are nested within other <ul> elements.

aNotCurrentClass string Opt  

Control the class attribute of all <a> elements that are not currently active or currently being viewed.

Also configurable via the Site or Theme contentRenderer.cfc's this.aNotCurrentClass setting.

siteID string Opt $.event('siteid')

You can optionally pass in a SiteID from another site managed under the same installation. It default's to the SiteID of the site currently being visited.

complete boolean Opt false

If true, links are output with the full URL, including the domain. Valid options are:

  • true
  • false

Usage

Use this function to output primary navigation.

Example

The following example outputs the primary nav up to two-levels deep.

<cfoutput>
<nav>
#m.dspPrimaryNav(
viewDepth=2
, id='navPrimary'
, class='nav navbar-nav'
, displayHome='always'
, closeFolders=false
, showCurrentChildrenOnly=false
, ulNestedClass='dropdown-menu'
, liHasKidsNestedClass='dropdown-submenu'
, aHasKidsClass='dropdown-toggle'
, aHasKidsAttributes='role="button" data-toggle="dropdown" data-target="##"'
)#
</nav>
</cfoutput>