I want an endpoint in the Element API plugin that shows the last event entries from the Venti Calendar plugin. The Element API guide tells that's possible to use the plugin with custom element types. But how?
1 Answer
I don't have the Venti Calendar plugin, so I can't test this, but it should be as simple as setting the elementType
propety to whatever custom element type the plugin has created and you want to use and (optionally) setting any criteria you want defined by the element type.
return [
'endpoints' => [
'news.json' => [
'elementType' => 'Venti_Event',
'criteria' => ['key' => 'value'],
'transformer' => function(Venti_EventModel $eventModel) {
return [
'key' => $eventModel->property,
];
},
},
]
];
-
-
-
-
-
I tried it with 'Venti_EventElementType' as elementType name after searching in the plugin files that was the problem ;) thanx for the answer! Jan 3, 2017 at 18:23