I was wondering if there was a way to fetch fields/content from children of a page section, eg, with the starterkit:
/api/pages/notes?select=children
returns:
{
"code": 200,
"data": {
"children": [
{
"id": "notes/across-the-ocean",
"num": 20180421,
"title": "Across the ocean",
"url": "https://kirby-starterkit.test/notes/across-the-ocean"
},
{
"id": "notes/a-night-in-the-forest",
"num": 20180625,
"title": "A night in the forest",
"url": "https://kirby-starterkit.test/notes/a-night-in-the-forest"
},
{
"id": "notes/in-the-jungle-of-sumatra",
"num": 20180731,
"title": "In the jungle of Sumatra",
"url": "https://kirby-starterkit.test/notes/in-the-jungle-of-sumatra"
},
{
"id": "notes/through-the-desert",
"num": 20180905,
"title": "Through the desert",
"url": "https://kirby-starterkit.test/notes/through-the-desert"
},
{
"id": "notes/himalaya-and-back",
"num": 20180926,
"title": "Himalaya and back",
"url": "https://kirby-starterkit.test/notes/himalaya-and-back"
},
{
"id": "notes/chasing-waterfalls",
"num": 20181005,
"title": "Chasing waterfalls",
"url": "https://kirby-starterkit.test/notes/chasing-waterfalls"
},
{
"id": "notes/exploring-the-universe",
"num": 20181031,
"title": "Exploring the universe",
"url": "https://kirby-starterkit.test/notes/exploring-the-universe"
}
]
},
"status": "ok",
"type": "model"
}
>
Is there a way to have the response include other fields, such as text
and gallery
:
{
"code": 200,
"data": {
"children": [
{
"id": "notes/across-the-ocean",
"num": 20180421,
"title": "Across the ocean",
"url": "https://kirby-starterkit.test/notes/across-the-ocean",
"data": {
"text": ...,
"gallery": ...,
}
},
Or is it only possible through building a custom JSON response as per the cookbook: https://getkirby.com/docs/cookbook/templating/generating-json