Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
iCal + google calendar questions
I’m creating an ical (.ics) stream with smd_calendar + rah_external_output. I’m now trying to integrate it with google calendar. There were a few things I can’t quite seem to figure out.
1. When I add the calendar (other calendars > add > add by url) it doesn’t seem to pick up the name of the calendar set in the ical header.
X-WR-CALNAME:Nacul
Instead I get something like: h4k6ujp4ra5bfei3d3v5bjlt94s1rsbv@import.calendar.google.com as the calendar name.
2. Can I create a one-click link on my site that will take a user to their google accounts and subscribes them to the ical stream?
edit: I found the solution to that one. In case anyone is curious: a link to : https://www.google.com/calendar/render?cid=http://domain.com/?rah_external_output=events.ics
seems to do the trick
3. When I update my ical stream, google calendar doesn’t pick up on it quickly… can something be done about that? Do CTags take care of that? And if so, how do i use them.
This is what the stream looks like
Thanks.
Last edited by JanDW (2010-09-06 06:25:09)
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline
Re: iCal + google calendar questions
were you doing something like adding a button to articles saying “add to my calendar”? i found this kind of integration very difficult, mainly because of time zone issues that are beyond my knowledge level.
Offline
Re: iCal + google calendar questions
Hi Elliot – no, that part I’ve got working.
I markup each event in the hcalendar microformat. To get UTC time to put in the title
attribute of the abbr
element, I use gmstrftime();
<abbr class="dtstart" title="<txp:php>echo gmstrftime('%Y%m%dT%H%M00Z', $thisarticle['posted'] );</txp:php>">...</abbr>
Hope that helps.
edit: I then use jQuery to extract the data from the hcalendar microformat and add a “add to gcal” link to the page). For the href, I just use jQuery.param()
to create a url like the one you can create here
Last edited by JanDW (2010-09-21 20:33:51)
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline
Re: iCal + google calendar questions
Hi Jan. Could you share your scripts here so I could use it, because I dont know how to extract the data with jQuery. Please! Thanks in advance!
Offline
Re: iCal + google calendar questions
Hi Robhert,
Replace www.yoursite.com
with the obvious, and replace organization in sprop:'name:Organisation'
.
So if you’ve marked up your events as hCalendar, the jQuery script below will loop through them, extract event data, create a url with parameters and insert it before .ical
in the page.
Here it is in action: http://tiaarchitects.com/events/darlingside-benefit-concert
You might want to have a look at the event publisher guide as well.
Good luck, hombre.
$(document).ready(function() {
$('.vevent').each(function(){
var $event = $(this);
addToCal($event);
});
//serializes the hcalendar format and submits it to google calendar
function addToCal($event){
//get all parameters from hcalendar
var $query = new Array();
$query['text'] = $event.find('.summary').text();
$query['dtstart']= $event.find('.dtstart').attr('title');
$query['dtend']= $event.find('.dtend').attr('title');
//make sure url doesn't get too long, use only first paragraph
$query['description'] = $event.find('.description p:first').text();
$query['location'] = $event.find('.location').text();
//build url for add to google calendar
var queryObj = {
action:'TEMPLATE',
text: $query['text'],
dates: $query['dtstart'] + '/' + $query['dtend'],
details: $query['description'],
location: $query['location'],
trp: 'false',
sprop:'http%3A%2F%2Fwww.yourwebsite.com',
sprop:'name:Organisation'
}
// insert link into the page
var $ical = $event.find('.ical');
var href = 'http://www.google.com/calendar/event?' + jQuery.param(queryObj);
$('<a href="" class="gcal" title="Post this event to Google Calendar.">Add to Google Calendar</a>')
.attr('href',href)
.insertBefore($ical);
//var permlink = 'http://www.yoursite.com/calendar/some-event';
//permlink = permlink.replace('http://www.','');
};
});
Last edited by JanDW (2011-01-29 16:26:40)
TXPDream – A Textpattern Tag Library for Adobe Dreamweaver. (updated for 4.2.0) | jdw_if_ajax – Only serve certain parts of a page when requested with AJAX
Offline