Skip to main content

getPageById

Get a single page by ID, with its form configurations and block markers.

Description​

Fetches a page by id and resolves to an IPagesEntity. Which fields it contains depends on the page type.

.getPageById(

,

);

Parameters schema​

Schema

id(required): number
ID of the page to fetch.
example: 1

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

Examples​

Minimal example​

const response = await Pages.getPageById(8);

Example with langCode​

const response = await Pages.getPageById(8, 'en_US');

Example response​

{
"id": 8,
"parentId": null,
"pageUrl": "blog",
"depth": 0,
"localizeInfos": {
"title": "Blog",
"htmlContent": "",
"plainContent": "",
"menuTitle": "Blog"
},
"isVisible": true,
"blocks": [
"slider"
],
"type": "common_page",
"templateIdentifier": "template",
"attributeSetIdentifier": "page",
"attributeValues": {
"text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"number": {
"type": "integer",
"value": 5,
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"real": {
"type": "real",
"value": 10,
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": false
},
"float": {
"type": "float",
"value": 12,
"isIcon": false,
"position": 3,
"additionalFields": {},
"isProductPreview": false
}
},
"moduleFormConfigs": [
{
"id": 9,
"formIdentifier": "full_form",
"moduleIdentifier": "content",
"isGlobal": false,
"isClosed": false,
"isModerate": true,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "blog",
"isNested": false
}
],
"formDataCount": 6281,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 6281
},
"nestedEntityIdentifiers": [],
"exceptionIds": []
},
{
"id": 3,
"formIdentifier": "file_form",
"moduleIdentifier": "content",
"isGlobal": false,
"isClosed": false,
"isModerate": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "blog",
"isNested": false
}
],
"formDataCount": 691,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 691
},
"nestedEntityIdentifiers": [],
"exceptionIds": []
},
{
"id": 2,
"formIdentifier": "test-form",
"moduleIdentifier": "content",
"isGlobal": false,
"isClosed": false,
"isModerate": false,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "blog",
"isNested": false
}
],
"formDataCount": 909,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 909
},
"nestedEntityIdentifiers": [],
"exceptionIds": []
}
],
"isSync": true,
"template": {
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
}

Response schema​

Schema: IPagesEntity

id: number
Object ID.
example: 8

parentId: number | null
ID of the parent page; null for a top-level page.
example: 10

pageUrl: string
URL of the page.
example: "blog"

depth: number
Nesting level of the page: 0 for a top-level page, 1 for its children, and so on.
example: 10

localizeInfos: ILocalizeInfo
Localized page content: title, menuTitle, htmlContent and plainContent.
example:

{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}

isVisible: boolean
Whether the page is visible.
example: true

type: PageType
Page type.
example: "common_page"

templateIdentifier: string | null
Marker of the linked template.
example: "template"

attributeSetIdentifier: string | null
Marker of the attribute set, or null if none is assigned.
example: "page"

attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:

{
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": {}
}
}

isSync: boolean
Whether the page's attribute index is up to date for the requested language.
example: true

template: object
Template linked to the page.
example:

{}

position: number
Position used for sorting.
example: 2

config: Record<string, number>
Output settings for catalog pages.
example:

{
"rowsPerPage": 1,
"productsPerRow": 1
}

products: number
Number of products linked to the page.
example: 0

childrenCount: number
Number of child pages.
example: 1

blocks: IBlockEntity[] | string[]
Blocks attached to the page: block objects or their markers.
example:

[
"product_block"
]

blocks.attributeValues: IAttributeValues
Attribute values keyed by marker; an empty object when there are none.
example:

{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
}
}

blocks.id: number
ID of the block.
example: 1234

blocks.localizeInfos: ILocalizeInfo
Localized data of the block.
example:

{
"title": "Example title"
}

blocks.version: number
Version number of the block.
example: 1

blocks.identifier: string
Marker of the block.
example: "block1"

blocks.type: BlockType
Type of the block.
example: "product"

blocks.position: number
Position of the block, used for sorting.
example: 1

blocks.templateIdentifier: string | null
Marker of the template used by the block, or null.
example: "template1"

blocks.isVisible: boolean
Whether the block is visible.
example: true

blocks.countElementsPerRow: number
Number of items per row in the block, if set.
example: 3

blocks.quantity: number
Quantity of items in the block, if applicable.
example: 5

blocks.similarProducts: IProductsResponse
Similar products for the block, as total and items.
example:

{
"total": 10,
"items": []
}

blocks.products: IProductsEntity[]
Products linked to the block.
example:

[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]

moduleFormConfigs: Array<IFormConfig>
Form configurations of the module linked to the page.

rating: IRating
Rating data: average value, likes and dislikes, and the calculation method.

total: string
Not returned by the Content API; use products for the number of linked products.
example: "10"

categoryPath: string | null
Category path; null for nested pages that have no category path of their own.
example: "catalog"

distance: number
Cosine distance to the query. Returned on every item by the semantic (vector) search endpoint.
example: 0.12


Usage examples​

Step-by-step walkthrough in the documentation:

Try it live​

Run this method in the JS SDK sandbox. On your first visit, connect your Project URL and App Token, then open: