Root page with navigation
Retrieve the root page with shared content elements and first level sub-pages to build the navigation:
http://mydomain.tld/api/cms/pages?filter[tag]=root&include=children,contents
In case the site uses more than one language and sets the lang
property for each page:
http://mydomain.tld/api/cms/pages?filter[tag]=root&filter[lang]=en&include=children,contents
The result will be a JSON:API response which looks like:
{
"meta": {
"baseurl": "http:\/\/mydomain.tld\/storage\/",
"page": {
"currentPage": 1,
"from": 1,
"lastPage": 1,
"perPage": 15,
"to": 1,
"total": 1
}
},
"jsonapi": {
"version": "1.0"
},
"links": {
"first": "http:\/\/mydomain.tld\/api\/cms\/pages?filter%5Btag%5D=root&include=children%2Ccontents&page%5Bnumber%5D=1&page%5Bsize%5D=15",
"last": "http:\/\/mydomain.tld\/api\/cms\/pages?filter%5Btag%5D=root&include=children%2Ccontents&page%5Bnumber%5D=1&page%5Bsize%5D=15"
},
"data": [
{
"type": "pages",
"id": "1",
"attributes": {
"parent_id": null,
"lang": "",
"slug": "",
"name": "Home",
"title": "Home | Laravel CMS",
"tag": "root",
"to": "",
"domain": "mydomain.tld",
"has": true,
"cache": 5,
"data": [
{
"text": "Welcome to Laravel CMS",
"type": "cms::heading"
}
],
"meta": {
"cms::meta": {
"text": "Laravel CMS is outstanding",
"type": "cms::meta"
}
},
"config": null,
"createdAt": "2023-05-01T09:36:30.000000Z",
"updatedAt": "2023-05-01T09:36:30.000000Z"
},
"relationships": {
"contents": {
"data": [
{
"type": "contents",
"id": "0187d6ab-b76d-75ee-8830-ab00b4259aa5"
}
]
},
"children": {
"data": [
{
"type": "pages",
"id": "2"
},
{
"type": "pages",
"id": "4"
},
{
"type": "pages",
"id": "5"
}
]
}
},
"links": {
"self": "http:\/\/mydomain.tld\/api\/cms\/pages\/1"
}
}
],
"included": [
{
"type": "contents",
"id": "0187d6ab-b76d-75ee-8830-ab00b4259aa5",
"attributes": {
"lang": "",
"data": {
"text": "Welcome to Laravel CMS",
"type": "cms::heading"
},
"createdAt": "2023-05-01T09:36:30.000000Z"
}
},
{
"type": "pages",
"id": "2",
"attributes": {
"parent_id": 1,
"lang": "",
"slug": "blog",
"name": "Blog",
"title": "Blog | Laravel CMS",
"tag": "blog",
"to": "",
"domain": "",
"has": true,
"cache": 5,
"data": null,
"meta": null,
"config": null,
"createdAt": "2023-05-01T09:36:30.000000Z",
"updatedAt": "2023-05-01T09:36:30.000000Z"
},
"links": {
"self": "http:\/\/mydomain.tld\/api\/cms\/pages\/2"
}
},
{
"type": "pages",
"id": "4",
"attributes": {
"parent_id": 1,
"lang": "",
"slug": "dev",
"name": "Dev",
"title": "For Developer | Laravel CMS",
"tag": "",
"to": "",
"domain": "",
"has": false,
"cache": 5,
"data": null,
"meta": null,
"config": null,
"createdAt": "2023-05-01T09:36:30.000000Z",
"updatedAt": "2023-05-01T09:36:30.000000Z"
},
"links": {
"self": "http:\/\/mydomain.tld\/api\/cms\/pages\/4"
}
},
{
"type": "pages",
"id": "5",
"attributes": {
"parent_id": 1,
"lang": "",
"slug": "hidden",
"name": "Hidden",
"title": "Hidden page | Laravel CMS",
"tag": "hidden",
"to": "",
"domain": "",
"has": false,
"cache": 5,
"data": null,
"meta": null,
"config": null,
"createdAt": "2023-05-01T09:36:30.000000Z",
"updatedAt": "2023-05-01T09:36:30.000000Z"
},
"links": {
"self": "http:\/\/mydomain.tld\/api\/cms\/pages\/5"
}
}
]
}
Comments