Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

GoogleCalendar

Summary: Embeds a Google Calendar in a PmWiki page
Version: 2006-09-30
Prerequisites: PmWiki 2.x
Status: Initial release
Maintainer: zkarj
Categories: Includes

Questions answered by this recipe

How can I embed a Google Calendar in a PmWiki page?

Description

Embeds a Google Calendar in a PmWiki page, for viewing.

To install, download googlecalendar.phpΔ and install in your cookbook directory, then add the following line to your config.php

 include_once('cookbook/googlecalendar.php');

See Notes below for usage.

Notes

This recipe adds a (:GoogleCalendar ... :) markup which can be placed in any page.

The minimal form is: (:GoogleCalendar calendar=myaddress@gmail.com:)

This will display the specified public calendar with default settings (see below). The calendar is displayed inside an HTML <iframe> element.

Additional, optional parameters may be specified as follows (defaults in bold).

title="My Calendar"

Specify a title to appear on your calendar. Default is "My Calendar". Best to avoid anything other than alphanumeric and spaces. Essentially anything that can appear unescaped in a URL is fine.

control=full
control=navonly
control=none

Specify what controls will be displayed. full controls will include a Google logo, your calendar title and buttons to increment and decrement the month displayed. navonly controls will omit the logo and title, but a small logo will appear in the bottom right corner, potentially overlaying content. none will remove all controls, meaning viewers cannot navigate to other months and the small logo in the corner is there.

mode=month
mode=agenda

Specify the type of calendar to display. month is a standard month calendar, agenda is a list of events.

width=640

Specify the width of the frame (and thus the calendar) in pixels. Default is 640.

height=610

Specify the height of the frame in pixels. Default is 610 which is just enough for the default calendar (produced with only the calendar= parameter). If the height is not enough to show the entire calendar, a scroll bar will appear in the frame. Note that the appearance of the calendar height is dependent on the following parameter - not this one.

items=5

Control the height of each row of the calendar by specifying the number of events that should fit. Only useful for mode=month.

week=Sun
week=Mon
week=Sat

Specify which day of the week is in the left-most column of the calendar. Only useful for mode=month.

bgcolor=#ffffff

Specify the background color of the frame. This is a standard HTML hex value including the leading #.

border=off
border=on

Specify whether a border is drawn in the frame. This is an appoximately 50% gray, single pixel border.

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

Comments

In general, only a "public" Google calendar will be shown. If you want to show a private calendar (which, of course, you would only do in a password protected page), use this form:

(:GoogleCalendar calendar=myaddress%40gmail.com&pvttk=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:)

Where xxx... is the key that you get from Google Calendar:

  • Settings (links at top left of page)
  • Calendar Settings / Calendars
  • Calendar Settings / My Calendars / Calendar / <my calendar's name>
  • <my calendar's name> Details / Calendar Details / Private Address (bottom of page) / HTML
  • Copy the link address, take the key from it

Davide Andrea 11/4/06

Valid XHTML Fix
Unfortunately, the current version of GoogleCalendar recipe does not give valid XHTML 1.0 Transitional. So, I've made some changes on the code to fix this. Here are my changes:

In 'googlecalendar.php' from line 29 to 47.
from:
------------------------------
  $output  = '<iframe src="http://www.google.com/calendar/embed?';
  $output .= 'src=' . $args['calendar'];
  $output .= '&title=' . $args['title'];
  if ($args['control'] == 'navonly') { $output .= '&chrome=NAVIGATION'; }
    elseif ($args['control'] == 'none') { $output .= '&chrome=NONE'; }
  if ($args['mode'] == 'agenda') { $output .= '&mode=AGENDA'; }
  $output .= '&epr=' . $args['items'];
  $output .= '&wkst=';
  if ($args['week'] == 'Sun') { $output .= '1'; }
    elseif ($args['week'] == 'Mon') { $output .= '2'; }
    else  { $output .= '7'; }
  if ($args['bgcolor']) { $output .= '&bgcolor=%23' . $args['bgcolor']; }
  $output .= '&height=' . $args['height'] . '"';
  if ($args['border'] == 'off') { $output .= ' style="border-width:0"'; }
    else { $output .= ' style="border:solid 1px #777"'; }
  $output .= ' width=' . $args['width'];
  $output .= ' frameborder="0"';
  $output .= ' height=' . $args['height'];
  $output .= '></iframe>';
------------------------------
to:
------------------------------
  $output  = '<iframe src="http://www.google.com/calendar/embed?';
  $output .= 'src=' . $args['calendar'];
  $output .= '&amp;title=' . $args['title'];
  if ($args['control'] == 'navonly') { $output .= '&amp;chrome=NAVIGATION'; }
    elseif ($args['control'] == 'none') { $output .= '&amp;chrome=NONE'; }
  if ($args['mode'] == 'agenda') { $output .= '&amp;mode=AGENDA'; }
  $output .= '&amp;epr=' . $args['items'];
  $output .= '&amp;wkst=';
  if ($args['week'] == 'Sun') { $output .= '1'; }
    elseif ($args['week'] == 'Mon') { $output .= '2'; }
    else  { $output .= '7'; }
  if ($args['bgcolor']) { $output .= '&amp;bgcolor=%23' . $args['bgcolor']; }
  $output .= '&amp;height=' . $args['height'] . '"';
  if ($args['border'] == 'off') { $output .= ' style="border-width:0"'; }
    else { $output .= ' style="border:solid 1px #777"'; }
  $output .= ' width="' . $args['width'] . '"';
  $output .= ' frameborder="0"';
  $output .= ' height="' . $args['height'] . '"';
  $output .= '></iframe>';
------------------------------

-2007/07/12 Diafygi


See Also

Contributors


I'm having trouble with the required codes to get this to work... it also puts a block of text at the top of the screen if it's used (?) This is the first recipe I've had trouble using!

I'm trying to make it display as 300x350 with the print icon, tabs, calendar list and time zone set to not show.

Also, what is the code to make it display other calendar info as well (:ie calendar + regional holidays calendar + local events calendar) There are checkboxes to add it to the standard mark up google provides.

Glen Patras (May 15, 2009)

The script gets some extras lines at the top. You have to get rid of all lines before

<?php

and replace this line by

<?php if (!defined('PmWiki')) exit ();

You also have to avoid the "#" character when specifying colors in bgcolor because the script adds it allready (which is not very handy after all).

Fabien Villard (Feb 2010)

User notes?: If you use, used or reviewed this recipe, you can add your name. The following format is recognized:
* (+) Optional positive comment. Name, date
* (-) Optional negative comment. Name, date

These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on February 02, 2010, at 11:29 AM