Skip to main content

getMenusByMarker

Get a menu by its marker.

Description​

Fetches a menu and its pages by the menu's marker. Resolves to an IMenusEntity.

.getMenusByMarker(

,

);

Parameters schema​

Schema

marker(required): string
Marker of the menu.
example: "main_menu"

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

Examples​

Minimal example​

const response = await Menus.getMenusByMarker('main_menu');

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
ID of the menu.
example: 1

identifier: string
Marker of the menu.
example: "main_menu"

localizeInfos: ILocalizeInfo
Localized menu data.
example:

{
"title": "menu"
}

pages: IMenusPages[]
Pages in the menu.
example:

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

pages.children: IMenusPages[]
Nested menu items (child pages).
example:

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

pages.id: number | null
ID of the page, or of the custom item when itemType is custom.
example: 1

pages.pageUrl: string | null
URL (marker) of the page; for a custom item (itemType: "custom"), the value set for the item, such as an external link.
example: "about"

pages.localizeInfos: ILocalizeInfo
Localized data of the item: title, menu title and content.
example:

{
"title": "menu"
}

pages.attributeValues: IAttributeValues
Attribute values of the page, keyed by attribute marker.
example:

{
"color": {
"type": "string",
"value": "red",
"isIcon": false,
"position": 0,
"additionalFields": {}
}
}

pages.position: number
Position used for sorting.
example: 1

pages.parentId: number | null
ID of the parent menu item; null for a top-level item.
example: null

pages.parentType: 'page' | 'custom' | null
Kind of the parent item: page or custom; null (with parentId: null) for a top-level item. Page ids and custom item ids overlap, so you need this field to identify the parent.
example: null

pages.itemType: 'page' | 'custom'
Kind of this item: page or custom. The item's children carry this value in parentType.
example: "page"