I've got a relatively simple setup running using SilverStripe 3.2.1 with the restfulserver addon and using a variety of widgets which are associated to a Page using the elemental addon.
When I make a GET request via the API to retrieve some of Page #1's data, I can see the associated ElementAreaID:
# GET /api/v1/Page/1.json?fields=Title,URLSegment,Content,ElementArea
{
"Title": "Welcome",
"URLSegment": "home",
"Content": "A bunch of HTML here from all the widgets in the page...",
"ElementArea": {
"className": "ElementalArea",
"href": "http://ss.local:3000/api/v1/ElementalArea/11.json",
"id": "11"
}
}
If I follow the links through the ElementalArea API calls it will list out all of the elements in my page:
# GET /api/v1/ElementalArea/11.json
{
"ID": "11",
"Widgets": [
{
"className": "Widget",
"href": "http://ss.local:3000/api/v1/Widget/9.json",
"id": 9
},
{
"className": "Widget",
"href": "http://ss.local:3000/api/v1/Widget/8.json",
"id": 8
},
...
]
}
And if I follow those API paths it will serve up the contents of the latest version of each of the Widgets.
My question is how can I include certain fields from the Widget DataObjects within the original Page field list?
I'd like ideally to have the Content field from each Widget be returned in an array with the initial Page API request.
For reference:
- A Page has one
ElementArea
- An
ElementArea
has manyWidget
s - A
Widget
contains content that I want for myPage