Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wanted to add support for the color attribute (http://fullcalendar.io/docs1/event_rendering/eventColor/) to easily set the color of a particular event rather than using fullcalendar_colors
and the color
module (which I couldn't make work for some reason). The attached one-line patch adds this support.
In my specific instance, I created a preprocessor function to add the color value to the #events render array from a color_field value:
/**
* Implements hook_preprocess_fullcalendar(&$variables)
*/
function mymodule_preprocess_fullcalendar(&$variables) {
foreach ($variables['element']['content']['events'] as $key => &$event) {
foreach ($event['#event'] as $delta => &$item) {
if (!empty($event['#entity']->field_event_category)) {
$term = taxonomy_term_load($event['#entity']->field_event_category[LANGUAGE_NONE][0]['target_id']);
if (!empty($term->field_color)) {
$item['#options']['attributes']['data-color'] = $term->field_color[LANGUAGE_NONE][0]['rgb'];
}
}
}
}
}
Comment | File | Size | Author |
---|---|---|---|
fullcalendar-support-color-attribute-x-1.patch | 625 bytes | jlyon |