Note: This widget does NOT work with WordPress 2.1 and up. Don’t bother trying.
————
I created a new widget for my blog. It’s a simple little thing that shows stuff from my Google Calendar. You can find it as my “Upcoming Events” sidebar, bottom left. Okay, so it doesn’t have much there yet, I need to add stuff to the calendar.
Anyway, here’s a link to it: gcalendar
If anybody has any suggestions on improving it, I’d love to hear ‘em.
——–
Note: I’ve updated the widget to use Google’s Calendar API properly. But in order to do that, I had to modify Wordpress’s built in MagpieRSS functions rather heavily. So read the readme.txt file for installation instructions before attempting to use it. Failure to install correctly will break your blog. Heck, it might do that anyway. So read carefully. ![]()
[...] Narendra Rocherolle asked me to convert the Google Calendar widget into a 30boxes capable widget. No problem, it only took like 10 minutes. [...]
Hi Otto - I believe there was a comment up here addressing this at some point, but is there a way to extract the Description field as well? If you could repost that info I’d definitely appreciate it.
Thanks for all your work!
@Matt: Thought it was done adding
echo $stuff[$iter]['content'];
after
echo $stuff[$iter]['title'];
in gcalendar.php, but please someone correct me if I’m wrong.
I also changed both to:
echo htmlentities($stuff[$iter]['title']);
echo htmlentities($stuff[$iter]['content']);
which took care of some accentuated letter problems I had.
Cheers!
@Matt: Thought it was done adding
echo $stuff[$iter]['content'];
after
echo $stuff[$iter]['title'];
in gcalendar.php, but please someone correct me if I’m wrong.
I also changed both to:
echo htmlentities($stuff[$iter]['title']);
echo htmlentities($stuff[$iter]['content']);
which took care of some accentuated letter problems I had.
Cheers!
Hello,
Thanks for this widget.
After install it as a widget I get the following error
Warning: Invalid argument supplied for foreach() in /home/.keanu/cambalache/cambalachemadrid.com/wp/wp-content/plugins/widgets/gcalendar.php on line 166
Some tip?
Thanks in advance
Otto,
Love the widget; is there a way to control how often it updates? My events are often out of date.
Seth, it updates once an hour at most. The only way to change this is to modify the rss-functions.php file, because that is built in.
If you look at my site, you will see the calendar info in the right margin; the dates are up-to-date now, but events that have passed sometimes take almost 24 hours to “fall off” the top of the list.
I don’t know what to tell you. The code says 60 minutes. Unless you’re using WP-Cache or something, it’ll update once an hour (depending on traffic to your site, of course).
The relevant piece of code is in rss-functions.php. Search that file for “MAGPIE_CACHE_AGE”. Now, that value can be overriden by something else anywhere in your Wordpress system, but my plugin does not override it.
THANK YOU so much! I’ve spent quite a bit of time trying to get a Google Calendar feed to work on the sidebar of my Wordpress blog… but because I am on Dreamhost, most of the plugins gave me an error because of Dreamhost’s security measures with the getfunction (I’m not very technical here, sorry). Yours is the first that I’ve gotten to work and it is indeed loverly and straightforward, so thank you thank you thank you.
Thank you very much Otto. I had Arturo’s same problem in PHP 4.
Adding an if (is_array($stuff)){…} check around the foreach loop will fix the error.
New lines 442-452:
if (is_array($stuff)) {
foreach ($stuff as $item)
{
$itemdate = getdate($item['date']);
if ($itemdate['mday'] == $day)
{ // found one
$todaysItems[$i]=$item;
$i++;
}
}
}
Hiya! Who’s currently using Otto’s Google Calendar Widget? I don’t see it on this blog; I’m interested in seeing some actual examples of usage — please provide URLs. Thanx in advance!
Hiya! Who’s currently using Otto’s Google Calendar Widget? I don’t see it on this blog; I’m interested in seeing some actual examples of usage — please provide URLs. Thanx in advance!
can we have the date apearance format on the side bar like
Month
Startday - FinishDay EventName
now it shows only start day.
Murad
Great! Exactely what I needed for our conference!
Otto/Adam, I had the same problem as Arturo did (”Invalid argument supplied for foreach()” @ line 166). Tried Adam’s fix but no joy… any other possibilities?
Thanks
Otto I installed Gcalendar on my new blog and it is working great. I have WordPress 2.1 and want to install the Mighty Seek Podcast Plugin and was wondering is your rss-functions.php causes problems for any other app that sends or receives RSS.
Thanks for the Great App!
Installed as advised… get the same error as Arturo and the suggested fix doesn’t do anything.
love the calendar, using it as a plugin (not a widget, though not for any particular reason other than I haven’t used widgets yet). The tooltip is displaying wrong, I assume. it’s causing jitter in Firefox in the whole sidebar. Is there a way to fix this? It also doesn’t seem to be getting the size or color information from the provided CSS (lightyellow & 150)in Firefox or (shudder) IE7.
nevermind, figured it out… it was the copyright symbol in the tooltip script.
Has anyone confirmed whether this conflicts with Mighty Seek’s Podcast plugin?
Is there any chance that a future version could: [a] optionally include a direct link to the google calendar (link and link title), and [b] optionally include the small calendar view above or below the list of events (so, show both). Even if not, wonderful plug-in… thanks!
Any ideas or experience out there how this plugin could be best included on a password-protected page?
The password protection only protects the content area of the page, so PHP code included in the page template is not protected.
The PHP execution plugins available seem a bit iffy when used with the rich text exitor.
I had GCalendar working great for about a month. I just upgraded my WP install to version 2.1.l and now the Widget still shows on the page with “My Claendar” written on top but there is no info showing below the title. Anyone have any ideas?
Wanted to warn others about the install of WP 2.1.1
Thanks!
Added the following to the end of the gcalendar.php file. Inserting the comment tag to the page content now includes a list of events on that page.
function add_calendar_to_content($content)
{
$tag_for_list = ‘‘;
// see whether the calendar should be included on this page
$pos = strpos($content, $tag_for_list);
if ($pos === false)
{
// tag wasn’t found, so leave the content alone
return $content;
}
else
{
$calendar_content = widget_do_gcalendar(’http://www.google.com/calendar/feeds/… blah blah …/basic’,50,’today’,'today + 1 year’,”,’j\.n\.Y\: ‘,true,false);
return str_replace($tag_for_list, $calendar_content, $content);
}
}
// Add a HTML comment tag for placing calendar in the content - hardwired parameters
add_filter(’the_content’, ‘add_calendar_to_content’);
Oops. Here’s the correct code. You also need to reactivate the plugin to get this working.
function add_calendar_to_content($content)
{
$tag_for_list = ‘‘;
$tag_for_calendar = ‘‘;
// see whether the calendar should be included on this page
$pos = strpos($content, $tag_for_list);
if ($pos === false)
{
// tag wasn’t found, so leave the content alone
return $content;
}
else
{
$calendar_content = widget_do_gcalendar(’http://www.google.com/calendar/feeds/… blah blah …/basic’,50,’today’,'today + 1 year’,”,’j\.n\.Y\: ‘,true,false);
return str_replace($tag_for_list, $calendar_content, $content);
}
}
// Add a HTML comment tag for placing calendar in the content - hardwired parameters
add_filter(’the_content’, ‘add_calendar_to_content’);
hey, great widget! thanks!!
[...] post to be informative of one of the widgets I stuck in the sidebar. This widget, which I found on this site has a wonderful function, now our upcoming google calendar events are displayed in the sidebar. [...]
I appreciate all the hard work you put into this, but it sure would help when people create a plugin that they link to an example or two of the thing working. Having to download it, activiate and make it live before seeing what it does is too cumbersome.
Otto/Adam, I too am having the same php 4 problem and the hack isn’t working. Here’s what I changed
in the code:
if (is_array($stuff)) {
foreach ($stuff as $item)
{
$itemdate = getdate($item['date']);
if ($itemdate['mon'] == $thismonth)
{
$newstuff[$i]=$item;
$i++;
}
}
}
I noticed that the code is slightly different from what Adam had previously shown. I’m not well gifted
in code and didn’t know if that made a difference.
Any help would be great as I’m doing this as a volunteer for my church.
[...] Google Calendar Widget » Nothing to see here - Possible contender for an events calendar I want to host with Google Calendar but display on the sidebar of my blog. There doesn’t seem to be too many of these on the market, let me tell you! [...]
[...] even easier: just use their GCal widget. If you’re using WordPress, you could try this Google Calendar Widget. 14. Synchronize with your desktop calendar(s). Calgoo, in public beta right now, is a Java-based [...]
Google Calendar…again…
After a hiatus, I have been working on a project that has me looking at platforms once again, and specifically, the tools necessary for advocacy and management of campaigns (no, I am not with a campaign this season). As I……
[...] je weblog. Als je een weblog gebruikt zoals Wordpress, kan je het eenvoudig laten zien met de
[...] 8. Vedere il calendario a tutto schermo. Se state avigando da un piccolo monitor, potrete trovare utile visualizzare il Calendario a tutto schermo, grazie all’estensione di Firefox Full Cal, che ci consente di accedere a questa modalit
Hi.
Thanx for the nice plugin!
Just wanted to let you know, I had to replace the line
$stuff[$count]['title']=$row["title"];
with
$stuff[$count]['title']=htmlentities($row["title"]);
to make it display German special characters (ÄÖÜß) in the titles correctly.
Is there a way to have the user change the month they view? Examaple have a forward and backward button above the calendar to change months?
no comments about the foreach error? no solutions. unfortunately, a nonworking plugin for a variety of people.
The foreach error means, basically, that it could not retrieve your feed. Sorry, I’ve kinda slacked off on development for this since I’m working on the picasa widget again.
Otto is correct, the foreach problem is because the widget don’t found the feed whith the calendar.
Why? because php 4.0 change the order getting the widget params and stores the feed url in $option['title'] and the title in $option['feed'] so when the script tries to retieve the feed you get the foreach error because it isn’t a xml archive to browse and get the events.
So, you have to change the code (lines 129-130):
$title = $options['title'];
$basicfeed = $options['feed'];
with this:
$title = $options['feed'];
$basicfeed = $options['title'];
I know that diferent versions of php changes the order of getting params in a function is a crazy idea but it really works!
Nice Widget… i like it..
Hello. Ken from comment #19.
I was just checking back to see if there were any updates. I made a couple of hacks to a copy of this plug in to add the link to the whole calendar (which I’d requested above), and I added a conditional so that all day events (which currently show up as starting at midnight) do not show a time at all. I’m testing for midnight, so if you actually had a midnight event, my hack won’t work for you. Otto, let me know if you care to see the hacks.
Thanks for the great plug-in!
I’m having some trouble having the widget show the correct amount of list items. On my site, I want the list to show 6 items, but it is showing all items for the time span. Any ideas on how to fix this?
Yes, I’m having the same problem as Ryan. I’ll keep working at it, but so far it’s showing the LONG list of items, not just the number I specify. Otherwise, seems to work well!
Whoops, words spoken too soon…it was working until I added an event in Google Calendar and now it went nuts…
[...] Google Calendar Widget is a widget that isn’t actually compatible with wordpress and requires modification of the default wordpress files to work. It is also a widget which doesn’t necessarily fit my needs. [...]
Got the same foreach trouble, at several lines, i’ve tried everything told here, and it don’t work… Hope that there will be a solution one day ! Thanks for your work
[...] I noticed is the failed google calendar feed into the wordpress sidebar.
[...] Visit [...]
Are you going to update this widget for use in WP 2.2?
Brian: Probably not anytime soon, no. WordPress has been damnably slow in revamping their RSS reader support. I’ve been trying to introduce better code into the WordPress core so that the rss-functions hacking is not required, but I’m not having much luck.
Sorry if people have asked this before me. But does the new WP 2.3 version change the situation, in terms of updating this plugin? If maybe the rss-support have improved or something like that?
thanks
Would like to know that too
[...] 8. Vedere il calendario a tutto schermo. Se state avigando da un piccolo monitor, potrete trovare utile visualizzare il Calendario a tutto schermo, grazie all’estensione di Firefox Full Cal, che ci consente di accedere a questa modalit
otto, need help here…after uploading everything in the instructions, i got this on my sidebar…
Fatal error: Cannot redeclare class magpierss in /home/shaikhta/public_html/blog/wp-includes/rss-functions.php on line 14
help me out?
oh and pls send me an email…i might not be coming back to your blog so soon…
I installed everything according to the readme.txt but it won´t show any dates, just the headline.
If i change it to show a monthly calender, i get a lot of “Invalid argument supplied for foreach()…” in lines: 329 and 441
nevermind, just noticed, that this widget wont work with 2.3.1
you should disable download for it if it won´t work with an actual release.
Works fine for me in WP 2.3.2
Thank you!
The plugin is great, I love it. Thanks for your work!
I’m wondering, though, if there’s any way to pull repeating events from google calendar? Right now it skips right over those.
Or even to specifically display only those events that repeat?
Thanks!
-Steven
It would be wonderful if I could enter multiple calendars. For example, if I have a google calendar for Work, Home, and Church, I’d love it to grab events off of all those calendars and then merge them, or perhaps show:
Work
event
event
Home
event
event
etc.
I second the motion to support multiple calendars.
Otto, just a note to let you know I have just updated to 2.6 and your plugin still works great. All this time I have kept the original rss-functions.php and with each update rename and then name it back. It is one of the best plugins I have. Thanks!
As mentioned, multiple calendars would be really great. I have an artist management site, with each artist requiring their own calendar to manage their schedule.