| Issue 803: | gcalFeed should be able to handle empty string | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I'm working on the gcal integration for a drupal module called fullcalender: http://drupal.org/project/fullcalendar. In the admin menu they can choose to leave the gcal option empty. But the gcalFeed goes crazy with a non correct feed. Could you just skip the feed stuff if the string is empty? (or malformed?) Part of the code I'm using, the settings are stored in the database. ---------------------------------------------------------------------- eventSources: [ $.fullCalendar.gcalFeed( Drupal.settings.fullcalendar.gcal_feed_url, { className: 'fc-event-default ' + Drupal.settings.fullcalendar.gcal_class_name, editable: (Drupal.settings.fullcalendar.gcal_editable == 'true') ? true : false, }
Jan 25, 2011
#1
plunke...@gmail.com
Feb 7, 2011
Could you add a fullcalendar.gcalFeedArray function to the gcal file? (Like we did in the attached file) If that is done we can remove our custom made gcal.js file. Greets, The fullcalendar drupal team
Feb 12, 2011
I think making a special case for an empty feed url is dealing with things on the wrong layer.
The eventSources option is an array that can naturally handle zero or more feeds.
Here is the best solution, working with currently existing features...
var eventSources = [];
if (Drupal.settings.fullcalendar.gcal_feed_url) {
eventSources.push(
$.fullCalendar.gcalFeed(
Drupal.settings.fullcalendar.gcal_feed_url,
{
className: 'fc-event-default ' + Drupal.settings.fullcalendar.gcal_class_name,
editable: (Drupal.settings.fullcalendar.gcal_editable == 'true') ? true : false,
}
);
);
}
$('#calendar').fullCalendar({
eventSources: eventSources
});
This will probably do the trick for you.
Status:
Done
Feb 12, 2011
NOOOO :(... The proposal changed in the comments that followed the initial post. Please look at the comments and the javascript file I attached in my previous comment. It's not about allowing an empty feed, it is about allowing an array of feeds. If you have a dynamic backend you don't know how many gcal feeds the user will enter. So our proposal (see comment 1 and 2) makes an extra function in the gcal.js file that allows an array of feeds. (I have this working locally with the patched function) If you're not planning to add this new function into fullcalendar we have to add our patched file to the project and we don't like forking the code. But I know we can't force you :)
Feb 13, 2011
sorry i didn't answer the question
but the fact remains... eventSources IS an ARRAY of feeds. you can do something like this...
$('#calendar').fullCalendar({
eventSources: [
$.fullCalendar.gcalFeed(
"http://www.google.com/your_feed_url/",
{
// put your options here
className: 'gcal-event',
editable: true,
currentTimezone: 'America/Chicago'
},
),
$.fullCalendar.gcalFeed(
"http://www.google.com/your_feed_url2/",
{
// put your options here
className: 'gcal-event2',
editable: false,
currentTimezone: 'America/New_York'
},
)
]
});
does this solve your problem???
Feb 14, 2011
Not rly... Lets say you have a system generating random google feed urls (a numer between 1 and 10). How many "$.fullCalendar.gcalFeed()" calls are you going to add in the js file? 1? 10? You can't dynamicly add "$.fullCalendar.gcalFeed()" calls. There is no way to put a loop in "eventsources: [ ... ]" So we made gcalFeed an array so we can support a unknown number of feeds.
Feb 14, 2011
Here is the full code we place into eventsources:
eventSources: [
// Add events from Drupal.
function(start, end, callback) {
var events = [];
$(index).find('.fullcalendar-event-details').each(function() {
events.push({
field: $(this).attr('field'),
index: $(this).attr('index'),
eid: $(this).attr('eid'),
entity_type: $(this).attr('entity_type'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
url: $(this).attr('href'),
allDay: ($(this).attr('allDay') === '1'),
className: $(this).attr('cn'),
editable: $(this).attr('editable'),
dom_id: index
});
});
callback(events);
},
// Add events from Google Calendar feeds.
$.fullCalendar.gcalFeedArray(settings.gcal)
]
As you can see we have an unknown number of events in our db we pass it through the function and it will add all the necessary data for us.
In the end you see our customised gcalFeedArray function call.
if we could call the gcalFeed function in the function above it we could loop through all our gcal feeds. But you can't do that at the moment. You have to "hardcode" the number of gcal feeds you would like to add. Same story for the json feeds btw...
Feb 14, 2011
You say "There is no way to put a loop in "eventsources: [ ... ]""
YES THERE IS. eventSources IS AN ARRAY. something like this would work...
// start out with an array with only your drupal event source
var eventSourcesArray = [
function(start, end, callback) {
var events = [];
$(index).find('.fullcalendar-event-details').each(function() {
events.push({
field: $(this).attr('field'),
index: $(this).attr('index'),
eid: $(this).attr('eid'),
entity_type: $(this).attr('entity_type'),
title: $(this).attr('title'),
start: $(this).attr('start'),
end: $(this).attr('end'),
url: $(this).attr('href'),
allDay: ($(this).attr('allDay') === '1'),
className: $(this).attr('cn'),
editable: $(this).attr('editable'),
dom_id: index
});
});
}
];
// loop through your gcal feeds, add them to the array
for (var i=0; i<settings.gcal.length; i++) {
eventSourcesArray.push(settings.gcal[i]);
}
// initialize fullcalendar with this array of event sources
$('#calendar').fullCalendar({
eventSources: eventSourcesArray
});
is this an acceptable solution for you???
Feb 14, 2011
Ow I get it now... I/We thought eventsources was some kind of special construction. This example explains a lot and is very usefull. Makes everyhting clear. Srry for this crappy conversation :). Next time I'm in this queue I hopefully have a better question. Or a patch for a great feature. |
|
| ► Sign in to add a comment |