New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to pass additional data to events json #51
Comments
I think the json approach sounds like a good one. More options to configure the appearance or behaviour of the calendar would be great. |
So... the latter one? All metadata would be automatically available on the client side without the need to add them to the json using a plugin hook handler? |
Sorry, I'm not sure what you mean by "all metadata". I meant that adding additional fields to the json object was fine. I don't think it would be necessary to store these in the database would it? |
Yes, I would need to save them to database. In my use case the events would be color coded. User could pick a color in create/edit form for each event. (I believe this was a default feature in Elgg 1.7 version?) |
No, colour coding was not a previous feature in this plugin. The event calendar has no actual concept of a calendar. It is just a collection of events contained by a user or group. Perhaps you could create a new "calendar configuration" object to store configuration metadata? Then when displaying the events associated with a container object, the code could also check to see if the container also contains a calendar configuration object and use it to customise the calendar if it exists by passing its metadata via JSON?. |
Or did you really want to have the information associated with just one event? If so, I'm not sure I like the idea of automatically copying all the event metadata to JSON as some of it may not be relevant to the display. |
Yes! I can add a colorpicker to the event edit form using elgg_extend_view(). Then I can save the color as metadata to the database using a plugin hook handler. The only problem is to get the additional metadata to the json returned by event_calendar_get_page_content_fullcalendar_events().
This is understandable. So how about triggering a plugin hook in event_calendar_get_page_content_fullcalendar_events()? Something like: // Allow other plugins to add/delete/modify the event data
$event_item = elgg_trigger_plugin_hook('prepare:json', 'event_calendar', $event, $event_item); I could then make a plugin hook handler that adds e.g. the backgroundColor to the event item: function myplugin_event_data_handler($hook, $type, $event_item, $entity) {
if ($entity->backgroundColor) {
$event_item['backgroundColor'] = $entity->backgroundColor;
}
return $event_item;
} At least I can't think of any better idea than a plugin hook at the moment... |
Interesting. The colour picker isn't my code. Sounds like a good idea though. I like your JSON solution. Should be useful for a number of things. |
By the way, I would be fine in this case if you added the colour picker to the main code. Just make it a plugin configurable option (toggled off by default). Please do that if you have the time and your client/employer is OK with it. |
Any preferences for the name of the hook? The 'prepare:json', 'event_calendar' was just the first thing that came to my mind.
Great! I'll open a separate issue for that. |
prepare:json seems fine to me and comparable to other similar Elgg plugin hooks. |
Hm... or 'prepare', 'event_calendar:json' in comparison to 'prepare', 'menu:site' in Elgg core? I'm not really sure. |
Yes, you're right. Best to make it specific or we may run into collisions with other plugins. |
Fixes #51 - Make it possible to pass additional data to events json
Closed by #52 |
I have the need to pass additional data (backgroundColor in particular) to the events json returned by event_calendar_get_page_content_fullcalendar_events(). I wonder what would be the best way to achieve this?
I suppose the full calendar view is the only one that has any use for backgroundColor and similar data, correct? So maybe the function could trigger a plugin hook?
Or would it be too excessive to attach all metadata (available to the current user) to the json? If this option was used other plugins could add metadata using events and plugin hooks, and all the added data would then be immediately available in the json on the client side.
How much metadata is there in a single event_calendar object? Is the latter one a bad idea?
The text was updated successfully, but these errors were encountered: