Hello, we are still a small community and we contribute and help in our spare time - and it was Christmas.
Your question:
It is possible, but you have to do multiple steps.
Create a collection with your fields.
If you don’t need numeric ids, you can use the default _id
field with mongodb id style.
For start_date
and end_date
, you can use the date field. If you need the part 00:00:00
in your output, you can copy and paste the date field component file into path/to/cockpit/config/tags/field-date.tag
and modifiy it to produce your exact date format. This way, the core component will be overwritten.
Use a select field for type
.
You can create your own field components, if you want to. I needed a custom date range field in the past and published it for inspiration: https://github.com/raffaelj/cockpit-scripts/blob/master/custom-fields/field-date-range.tag
Custom rest api output
You can create your own api endpoint, that produces the format, you want. Create a file /cockpit/config/api/myCustomEndpoint.php
and return your format.
<?php
$data = cockpit('collections')->find('calendar');
$collections = ['sections' => ['...' => '...']];
return compact('data', 'collections');