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.
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’];afterecho $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!!
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.
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…
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
Are you going to update this widget for use in WP 2.2?