2 of 2
2
iCal plugin
Posted: 17 June 2008 11:57 PM   [ Ignore ]   [ # 19 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1590
Joined  01-05-2007

Hi DFBills,

Can you post a fully working template for me to view? You seem to have mixed PHP and XML in one go up there and I’m a little confused as to how to use the code.

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 18 June 2008 06:34 AM   [ Ignore ]   [ # 20 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  113
Joined  11-12-2002

My previous post is the fully working template.  It does seem overly simple, but everything you need is right there.  It is a mix of PHP, EE and of course XML.  Let me run through it for you.

In the first block of PHP, I’m getting the current date in a format I can use and storing as a variable.  Specifically, last month in ‘d-m-Y’ format and next year in ‘d-m-Y’ format.

<?php
// last month in 'd-m-Y' format
$uts['lastmonth'] = strtotime( '-1 months' ); // or, strtotime( 'yesterday' );
$last_month = date( 'Y-m-d g:i A', $uts['lastmonth'] );

// next year in 'd-m-Y' format
$uts['nextyear'] = strtotime( '+1 years' ); // or, strtotime( 'yesterday' );
$next_year = date( 'Y-m-d g:i A', $uts['nextyear'] );
?>

Now, we start into XML as required by the vCal standard.

BEGIN:VCALENDAR
VERSION
:2.0
X
-WR-CALNAME:BMI Event Calendar
PRODID
:-//BMI/ Events//NONSGML v1.0//EN
X-WR-TIMEZONE:US/Eastern

Now, some standard EE code to get weblog data.  Here’s where I use those PHP date variables we grabbed at the beginning to limit the data returned by EE.  My weblog has > 20,000 events listed, so I list one month back and one year forward.

{exp:weblog:entries weblog="events" status="not closed" show_future_entries="yes" disable="member_data|pagination|trackbacks|categories" show_expired="no" orderby="date" sort="asc" start_on="<?php echo $last_month; ?>" stop_before="<?php echo $next_year; ?>" limit="1000"}

This data is wrapped in the proper XML formatting.  On my calendar, I don’t have proper times set in the weblog entries, so I leave them at midnight. (T120001)

BEGIN:VEVENT
UID
:{entry_id}
DTSTAMP
:{entry_date format="%Y%m%dT%H%i%sZ"}
DTSTART
;VALUE=DATE:{entry_date format="%Y%m%d"}T120001
DTEND
;VALUE=DATE:{entry_date format="%Y%m%d"}T120002

Here’s where I had to cleanup the data a bit to conform to the strict vCal spec with my own little vcal_encode plugin.  (vCal doesn’t like extended characters, linebreaks, etc.)

SUMMARY:{exp:vcal_encode}{title}{/exp:vcal_encode}
DESCRIPTION
:{exp:vcal_encode}{long}{/exp:vcal_encode}

Finally, I wrap up the template by closing the vCal file and the EE tags.

END:VEVENT
{
/exp:weblog:entries}
END
:VCALENDAR

Remember that this template must be served from EE as XML and PHP must be enabled for it to work properly.  You may have named fields differently from mine, but you should be able to just plug those right in.

One final tip- I found it very helpful to debug the rendered code using curl at the command line.  On my setup, I just pipe it into TextMate like this:

curl http://www.bmi.com/events/ical | mate

Profile
 
 
Posted: 18 June 2008 06:53 AM   [ Ignore ]   [ # 21 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  203
Joined  02-10-2006
rish - 21 April 2006 03:27 AM

I think we’re going to see all sorts of neat things revolving around Google Calendar real soon, they released a calendar API today and you can subscribe to Google Calendars from iCal.

http://www.google.com/calendar/
http://code.google.com/apis/gdata/calendar.html

Hey Guys,

We are actually in the process of writing a complete module with full Google Calendar support with in integrated template and tagging parameters.

We are going to start testing it out on some sites in the next month.

Brandon

Profile
 
 
Posted: 18 June 2008 06:53 AM   [ Ignore ]   [ # 22 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  113
Joined  11-12-2002

Sounds sweet

Profile
 
 
Posted: 18 June 2008 06:59 AM   [ Ignore ]   [ # 23 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1590
Joined  01-05-2007
bjsteiger - 18 June 2008 06:53 AM
rish - 21 April 2006 03:27 AM

I think we’re going to see all sorts of neat things revolving around Google Calendar real soon, they released a calendar API today and you can subscribe to Google Calendars from iCal.

http://www.google.com/calendar/
http://code.google.com/apis/gdata/calendar.html

Hey Guys,

We are actually in the process of writing a complete module with full Google Calendar support with in integrated template and tagging parameters.

We are going to start testing it out on some sites in the next month.

Brandon

Yes please!

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
Posted: 08 September 2008 12:56 AM   [ Ignore ]   [ # 24 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  507
Joined  04-23-2006

*woot*

How’s the development of this module coming along?

 Signature 

OLD username was jammo, NEW username is OrganizedFellow

It’s a struggle even to keep focused. This is the best of my AD/HD & GTD.
The exceptionally slow growth of my web dev projects is eclipsed by my patience, understanding and desire to learn AS MUCH AS POSSIBLE as I slowly progress.

Profile
 
 
Posted: 23 November 2008 01:22 PM   [ Ignore ]   [ # 25 ]  
Grad Student
Avatar
Rank
Total Posts:  48
Joined  03-07-2008

I have followed dfbills instructions to a t and still I cannot import the events to Google Calendar. I always get a “Can’t parse the calendar” error from gCal. Importing into iCal works fine.

The calendar in question is here: http://wolfart.nl/feeds/agenda-ical.xml

Profile
 
 
   
2 of 2
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 64878 Total Logged-in Users: 66
Total Topics: 81804 Total Anonymous Users: 41
Total Replies: 439753 Total Guests: 300
Total Posts: 521557    
Members ( View Memberlist )
Newest Members:  pticketdxrsmdanbilly8hrkiliwysso50kexpressoKlaasdarrenstylestravelerjcaton