Download at: https://github.com/r.../MarkupLoadGCal
USAGE
The MarkupLoadRSS module is used from your template files. To use it, you get a copy of the module, tell it what URL to load from (with the load method), and then execute a find() query with a selector string. It works basically the same as a $pages->find("selector string").
<?php
$cal = $modules->get("MarkupLoadGCal");
$cal->load('http://calendar XML feed');
$items = $cal->find('from=2011-12-1, to=2011-12-31');
foreach($items as $item) echo "<p>{$item->title}</p>";To get a Google calendar URL, you would go into your (or another) calendar on Google and click to the calendar's settings. At the bottom of the screen, you will see a section called "Calendar Address" with XML, ICAL, and HTML. Copy the XML address, and use that with this module. If you just want one to test with, use the one from my examples below: http://www.google.co...com/public/full
Note: you must use the 'full' not 'basic' calendar from Google Calendar. You can identify if you've got the right one because it will end with 'full' rather than 'basic', as in the URL above.
Selector Properties
The selector properties you may provide to find() are:
- from: Starting date in any common date/time format (or unix timestamp).
- to: Ending date in any common date/time format (or unix timestamp).
- keywords: Keyword(s) to search for in the Google calendar events.
- limit: Max number of items to load (default = 100).
- sort: May be 'date', '-date', 'modified' or '-modified'.
- html: Set to '0' if you don't want the event description in HTML.
Calendar Item (Event) Properties
Each calendar item has the following properties:
- title: The title of the event
- description: Detailed description of the event (in HTML, unless disabled)
- location: Where the event will take place
- author: Author of this item
- from: Timestamp of when the event begins
- to: Timestamp of when the event ends
- dateFrom: Formatted date string of when the event begins
- dateTo: Formatted date string of when the event ends
EXAMPLES
Example #1: Simplest example
<?php
// get the calendar module
$cal = $modules->get("MarkupLoadGCal");
// set the feed URL: may be any google calendar XML feed URL
$cal->load('http://www.google.com/calendar/feeds/3icgo6ucgvsf6bi5orld9moqqc%40group.calendar.google.com/public/full');
// find all items for December, 2011
$items = $cal->find('from=2011-12-1, to=2011-12-31');
// render items using built-in rendering
echo $items->render();Example #2: Rendering your own items
<?php
$cal = $modules->get("MarkupLoadGCal");
$cal->load('http://www.google.com/calendar/feeds/3icgo6ucgvsf6bi5orld9moqqc%40group.calendar.google.com/public/full');
$items = $cal->find('from=2011-12-1, to=2011-12-31');
foreach($items as $item) {
echo "
<h2>{$item->title}</h2>
<p>
<b>Date From:</b> {$item->dateFrom} (Timestamp: {$item->from}) <br />
<b>Date To:</b> {$item->dateTo} (Timestamp: {$item->to}) <br />
<b>Location:</b> {$item->location} <br />
<b>Author:</b> {$item->author}
</p>
{$item->description}
";
}Example #3: Finding Keywords
<?php
$cal = $modules->get("MarkupLoadGCal");
$cal->load('http://www.google.com/calendar/feeds/3icgo6ucgvsf6bi5orld9moqqc%40group.calendar.google.com/public/full');
$items = $cal->find("from=Aug 1 2011, to=Dec 1 2011, keywords=Eddie Owen");
echo $items->render();ADDITIONAL INFO
Options
See the module's class file (MarkupLoadGCal) for a description of all options in the comments of the $options and $markup arrays at the top of the class file.
Handling Errors
If an error occurred when loading the feed, the $cal will have an 'error' property populated with a message of what error occurred:
<?php
$items = $cal->find("...");
if(empty($items) && $cal->error) {
// an error occurred
echo "Error! " . $cal->error;
}$items will be blank if an error occurs, but it will always be of the same type, so it's up to you whether you want to detect errors. If you don't, then your calendar output will just indicate that nothing was found.
Cache
By default your calendar queries are cached for an hour. You can change the cache time by setting the $cal->cache property to the number of seconds you want it to cache.
---
Edit: Added note that you must use the 'full' google calendar feed rather than the 'basic' one.













