Skip to main content

getPageByUrl

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

Description​

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

.getPageByUrl(

,

);

Parameters schema​

Schema

url(required): string
Page URL.
example: "about"

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

Examples​

Minimal example​

const response = await Pages.getPageByUrl('blog1');

Example with langCode​

const response = await Pages.getPageByUrl('blog1', 'en_US');

Example response​

{
"id": 9,
"parentId": 8,
"pageUrl": "blog1",
"depth": 1,
"localizeInfos": {
"title": "Blog 1",
"htmlContent": "",
"plainContent": "",
"menuTitle": "Blog 1"
},
"isVisible": true,
"blocks": [],
"type": "common_page",
"templateIdentifier": null,
"attributeSetIdentifier": null,
"attributeValues": {},
"moduleFormConfigs": [],
"isSync": false
}

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: