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?

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,
                ];
            },
        },
    ]
];
| improve this answer | |
  • The custom element type is "Venti_Event". – aran Jan 3 '17 at 1:09
  • Cool... I assume there is a Venti_EventModel as well? – Brad Bell Jan 3 '17 at 3:06
  • Yes that would be it Venti_EventModel – aran Jan 3 '17 at 3:27
  • Updated answer! – Brad Bell Jan 3 '17 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! – Maarten Heideman Jan 3 '17 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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