Skip to main content

getMenusByMarker

The 'Menus' module defines the structure and navigation of your site.

Description​

It provides visitors with an easy way to move through sections of your application and find the information they need.

This method retrieves a single menu object based on its marker (marker) from the API. It returns a Promise that resolves to a single menu object IMenusEntity as a object with included pages.

Menus.getMenusByMarker(

marker*, langCode

);

Parameters schema​

Schema

marker(required): string
Menu marker
example: "main_menu"

langCode: string
Language code. Default: "en_US"
example: "en_US"

Examples​

Minimal example​

const response = await Menus.getMenusByMarker('my-marker')

Example response​

{
"id": 1,
"identifier": "main_menu",
"localizeInfos": {
"title": "menu"
},
"pages": [
{
"id": 8,
"pageUrl": "blog",
"localizeInfos": {
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
},
"attributeValues": {},
"parentId": null,
"parentType": null,
"position": 1,
"itemType": "page",
"children": [
{
"id": 9,
"pageUrl": "blog1",
"localizeInfos": {
"title": "Blog 1",
"menuTitle": "Blog 1",
"htmlContent": "",
"plainContent": ""
},
"attributeValues": {},
"parentId": 8,
"parentType": "page",
"position": 1,
"itemType": "page",
"children": []
}
]
},
{
"id": 10,
"pageUrl": "catalog",
"localizeInfos": {
"title": "Catalog",
"menuTitle": "Catalog",
"htmlContent": "",
"plainContent": ""
},
"attributeValues": {},
"parentId": null,
"parentType": null,
"position": 2,
"itemType": "page",
"children": []
}
]
}

Response schema​

Schema: IMenusEntity

id: number
The unique identifier of the menu.
example: 1

identifier: string
The menu identifier.
example: "main_menu"

localizeInfos: ILocalizeInfo
Contains localization information.
example:

{
"title": "menu"
}

pages: IMenusPages[]
Array of menu pages.
example:

[
{
"id": null,
"pageUrl": null,
"localizeInfos": {},
"attributeValues": {},
"parentId": null,
"position": 1
}
]

pages.children: IMenusPages[]
Contains array with child page objects.
example:

[
{
"id": null,
"pageUrl": null,
"localizeInfos": {},
"attributeValues": {},
"parentId": null,
"position": 1
}
]

pages.id: number | null
The unique identifier of the menu.
example: 1

pages.pageUrl: string | null
The page url string.
example: "about"

pages.localizeInfos: ILocalizeInfo
The menu data, taking into account localization.
example:

{
"title": "menu"
}

pages.attributeValues: IAttributeValues
Attributes sets.
example:

{
"color": "red",
"size": "large"
}

pages.position: number
The menu position.
example: 1

pages.parentId: number | null
The menu parent id.
example: null

pages.parentType: 'page' | 'custom' | null
Kind of the parent item: page for a menu page, custom for a custom item; null together with parentId means top level. Page ids and custom item ids overlap, so the parent is ambiguous without it.
example: null

pages.itemType: 'page' | 'custom'
Kind of this item itself: page or custom. This is the value the item's children must pass in parentType.
example: "page"