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
    Commented Jan 3, 2017 at 1:09
  • Cool... I assume there is a Venti_EventModel as well?
    – Brad Bell
    Commented Jan 3, 2017 at 3:06
  • Yes that would be it Venti_EventModel
    – a-am
    Commented Jan 3, 2017 at 3:27
  • Updated answer!
    – Brad Bell
    Commented 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! Commented Jan 3, 2017 at 18:23

Your Answer

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

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