Get Sub Navigation by URL API

The Get Sub Navigation by URL API lets you display the sub navigation for an individual navigation item when the URL of that item or it's children matches the current URL of the page being viewed.

A lot of website designs call for main navigation to be horizontal across the top of the website and then in a sidebar to display navigation that is specific to the section of the website being viewed. Often that navigation in the sidebar is sub navigation for an item in the main navigation. This API makes it easy to automatically display that sub navigation in the sidebar (or wherever you want) without having to individually specify the sub navigation for each page. Instead, the system will detect based on the URL of the page which sub navigation to show.

Essentially this API looks at the URL for the page, finds the navigation item that matches the URL and then finds the top-level parent navigation item for the match. By default the child navigation items for that top-level parent are the items that will be used. You can change that and show a different level of sub-navigation by changing the "level" parameter.

Some of the API parameters correspond with individual settings for the navigation menu being used. If you don't need to override those values then you can simply omit them.

Learn more about APIs.

Minimum Tag

{{ _api.site.navigation.getSubNavigationByUrl.key('main'.templateId('13') }}

API Tag Parameters

ParameterDescription
getParentItem Whether or not to include the parent navigation item when getting sub-navigation items.

Type: String

Accepted Values: yes, no, true or false

Default Value: no

Example: getParentItem('yes')
key Required

The key of the navigation menu to use

Type: String

Example:
key('main')
level The level of navigation to get sub navigation for.

1 means the top level navigation.
2 means the first level of sub navigation.
3 means the second level of sub navigation.

If the value is 1 then sub navigation for a top level item will be retrieved.

If the value is 2 then the sub navigation for a first-level sub navigation item will be retrieved.

Type: Integer

Default Value: 1

Example:
level('2')
parentId If this is set then only the sub-navigation items for the item with the specified id will be shown.

Type: Integer

Example:
parentId('3')
preloadImages Whether or not to preload images if any of the navigation items use images instead of text.
Defaults to the value set for the navigation menu.

Type: String

Accepted Values: yes, no, true or false

Example: preloadImages('yes')
showSubNav Whether or not to show sub navigation.
Defaults to the value set for the navigation menu.

"yes" means to show sub navigation when necessary.
"all" means to show sub navigation all the time. this is useful for navigation needing drop-down styles.
"no" means to not show sub navigation ever.

Type: String

Accepted Values:
yes,all,no

Example:
showSubNav('all')
templateId Required

The numeric id of the navigation template to use to display the menu.
Defaults to the value set for the navigation menu.

Type: Integer

Example:
templateId('6')
url You can optionally specify the URL that you want to base getting the sub navigation based.

This could be useful if you have navigation that links to the categories of an app and you want to show that same navigation when on an app item detail page. In those cases the individual app items aren't in the navigation so the API often doesn't return any data. You can specify the item's category URL to get the appropriate sub navigation information.

Type: String

Example:
url('/path/to/page')