getPageById
Mengambil objek halaman tunggal dengan informasi tentang formulir, blok, dan menu yang terlampir pada halaman.
Deskripsi
Metode ini mengambil objek halaman tunggal berdasarkan pengidentifikasi (id) dari API. Ini mengembalikan Promise yang menyelesaikan objek halaman IPagesEntity, dengan objek spesifik tergantung pada jenis halaman yang dikembalikan.
Halaman.getPageById(
id*,
langCode
);
Skema parameter
Skema
id(required): number
Pengidentifikasi unik dari halaman yang akan diambil
contoh: 1
langCode: string
Kode bahasa. Default: "en_US"
contoh: "en_US"
Contoh
Contoh minimal
const response = await Pages.getPageById(1);
Contoh dengan atribut
const response = await Pages.getPageById(1, 'en_US');
Contoh respons
{
"id": 8,
"parentId": null,
"pageUrl": "blog",
"depth": 0,
"localizeInfos": {
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
},
"isVisible": true,
"blocks": [
"slider"
],
"type": "common_page",
"templateIdentifier": "template",
"attributeSetIdentifier": "page",
"attributeValues": {
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": {}
},
"number": {
"type": "integer",
"value": 0,
"position": 1,
"additionalFields": {}
},
"real": {
"type": "real",
"value": "",
"position": 2,
"additionalFields": {}
},
"float": {
"type": "float",
"value": 0,
"position": 3,
"additionalFields": {}
}
},
"moduleFormConfigs": [
{
"id": 9,
"formIdentifier": "full_form",
"moduleIdentifier": "content",
"isGlobal": false,
"isClosed": false,
"isModerate": true,
"viewOnlyMyData": false,
"commentOnlyMyData": false,
"entityIdentifiers": [
{
"id": "blog",
"isNested": false
}
],
"formDataCount": 4827,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 4827
},
"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": 556,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 556
},
"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": 775,
"ratingCalculation": "average",
"allowHalfRatings": null,
"maxRatingScale": null,
"isAnonymous": null,
"allowRerating": null,
"isRating": null,
"entityFormDataCount": {
"blog": 775
},
"nestedEntityIdentifiers": [],
"exceptionIds": []
}
],
"isSync": true,
"template": {
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
}
Skema respons
Skema: IPagesEntity
id: number
Pengidentifikasi objek.
contoh: 8
parentId: number | null
Id dari halaman induk, jika berisi null, maka itu adalah halaman tingkat atas.
contoh: 10
pageUrl: string
URL halaman yang unik.
contoh: "blog"
depth: number
Kedalaman nesting halaman relatif terhadap parentId.
contoh: 10
localizeInfos: ILocalizeInfo
Nama halaman, dengan mempertimbangkan lokalisasi.
contoh:
{
"title": "Blog",
"menuTitle": "Blog",
"htmlContent": "",
"plainContent": ""
}
isVisible: boolean
Tanda visibilitas halaman.
contoh: true
type: PageType
Tipe halaman.
contoh: "common_page"
templateIdentifier: string | null
Id pengguna dari template yang terhubung.
contoh: "template"
attributeSetIdentifier: string | null
Set id atribut.
contoh: "page"
attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong jika tidak ada.
contoh:
{
"text": {
"type": "string",
"value": "some text",
"position": 0,
"additionalFields": []
}
}
isSync: boolean
Indikasi pengindeksan halaman.
contoh: true
template: object
Objek template.
contoh:
{}
position: number
Nomor item (untuk pengurutan).
contoh: 2
config: Record<string, number>
Pengaturan output untuk halaman katalog.
contoh:
{
"rowsPerPage": 1,
"productsPerRow": 1
}
products: number
Jumlah produk yang terhubung ke halaman.
contoh: 0
childrenCount: number
Jumlah anak.
contoh: 1
blocks: IBlockEntity[] | string[]
blok.
contoh:
{
"id": 4,
"attributeSetIdentifier": null,
"title": "Template",
"generalTypeId": 4,
"identifier": "template",
"version": 0,
"generalTypeName": "catalog_page",
"attributeValues": {},
"position": 1
}
blocks.attributeValues: IAttributeValues
Peta nilai atribut yang dikunci oleh penanda; objek kosong jika tidak ada.
contoh:
{
"block-text": {
"type": "string",
"value": "some text",
"isIcon": false,
"position": 0,
"additionalFields": [],
"isProductPreview": false
}
}
blocks.id: number
Pengidentifikasi unik dari blok.
contoh: 1234
blocks.localizeInfos: ILocalizeInfo
Informasi lokalisasi untuk blok.
contoh:
{
"key": "value"
}
blocks.version: number
Versi entitas blok.
contoh: 1
blocks.identifier: string
Pengidentifikasi string unik untuk blok.
contoh: "block1"
blocks.type: BlockType
Tipe blok.
contoh: "product"
blocks.position: number
Posisi blok untuk pengurutan.
contoh: 1
blocks.templateIdentifier: string | null
Pengidentifikasi untuk template yang digunakan oleh blok, atau null jika tidak berlaku.
contoh: "template1"
blocks.isVisible: boolean
Menunjukkan apakah blok terlihat.
contoh: true
blocks.countElementsPerRow: number
Jumlah elemen yang ditampilkan per baris dalam blok, jika berlaku.
contoh: 3
blocks.quantity: number
Jumlah item dalam blok, jika berlaku.
contoh: 5
blocks.similarProducts: IProductsResponse
Respons yang berisi produk serupa yang terkait dengan blok.
contoh:
{
"total": 10,
"items": []
}
blocks.products: IProductsEntity[]
Array entitas produk yang terkait dengan blok.
contoh:
[
{
"id": 1,
"name": "Product 1"
},
{
"id": 2,
"name": "Product 2"
}
]
moduleFormConfigs: Array<IFormConfig>
Konfigurasi formulir modul yang terhubung ke halaman.
rating: IRating
Data penilaian.
total: string
Jumlah total produk yang terhubung ke halaman.
contoh: "10"
categoryPath: string | null
String jalur kategori; null untuk halaman bersarang yang tidak memiliki jalur kategori sendiri.
contoh: "catalog"
Contoh penggunaan
Panduan langkah demi langkah dalam dokumentasi:
- Ambil halaman berdasarkan ID — ambil satu halaman CMS berdasarkan ID numeriknya.
Coba secara langsung
Jalankan metode ini secara interaktif di JS SDK sandbox — sambungkan URL Proyek dan Token Aplikasi Anda pada kunjungan pertama, lalu buka:
- Ambil halaman berdasarkan ID — ambil satu halaman CMS berdasarkan ID numeriknya.