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.
We recently created a calendar that uses two Google Calendar feeds, but for some reason one of the feeds was showing duplicate events.
After examining the css we saw there were classes missing from the duplicate events.
We decided to implement the fullcalendar api by doing the following in our MODULENAME.module file:
/**
* Implements hook_fullcalendar_api().
*/
function MODULENAME_fullcalendar_api() {
return array(
'api' => fullcalendar_api_version(),
);
}
/**
* Implements hook_fullcalendar_options_info().
*/
function MODULENAME_fullcalendar_options_info() {
return array(
'MODULENAME' => array(
'js' => TRUE,
'no_fieldset' => TRUE,
'weight' => 5,
),
);
}
And then in the sites/all/modules/MODULENAME/js/MODULENAME.fullcalendar.js file:
(function($) {
Drupal.fullcalendar.plugins.MODULENAME = {
options: function (fullcalendar, settings) {
return {
eventRender: function(event, element, view) {
// Here is where the class does NOT have the additional class information we have in "CSS class" for the "
FullCalendar: Google Calendar" field setting, so it gets REMOVED from display BEFORE render...
if (element.attr("class") == 'fc-event fc-event-hori fc-event-start fc-event-end') { return false; }
}
};
}
};
}(jQuery));
Please review and let me know if there is an easier way to unwanted events from the feed from showing in the fullcalendar.
Thank you.
Comments