1

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 1

2

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,
                ];
            },
        },
    ]
];
5
  • The custom element type is "Venti_Event".
    – a-am
    Jan 3, 2017 at 1:09
  • Cool... I assume there is a Venti_EventModel as well?
    – Brad Bell
    Jan 3, 2017 at 3:06
  • Yes that would be it Venti_EventModel
    – a-am
    Jan 3, 2017 at 3:27
  • Updated answer!
    – Brad Bell
    Jan 3, 2017 at 4:33
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.