iCalendar output for CGcalendar (adding event to user's personal calendar)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
JeremyBASS

iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by JeremyBASS »

Hello, so here as another simple trick to do...


UDT:    addEvent

Code: Select all




$filename="uploads/calendarEvents/".$params['EventName'].".ics";

if(file_exists($filename)){

}else{
if(!file_exists("uploads/calendarEvents/")){
     mkdir("uploads/calendarEvents/", 0777);
}
	$ourFileName = $filename;
	$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
	fclose($ourFileHandle);
$DESCRIPTION=mysql_real_escape_string ($params['DESCRIPTION']);
$event="BEGIN:VCALENDAR
PRODID:-//NCITA//northcentralidaho.org 1.0//EN
VERSION:1.0
BEGIN:VEVENT
BEGIN:VTIMEZONE
TZID:US-Pacific
LAST-MODIFIED:19870101T000000Z
TZURL:http://zones.stds_r_us.net/tz/US-Pacific
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=11
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=3
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE
URL:http://www.northcentralidaho.org
ORGANIZER:MAILTO:info@northcentralidaho.info
DTSTART;TZID=US-Pacific:".$params['DTSTART']."
DTEND;TZID=US-Pacific:".$params['DTEND']."
LOCATION:".$params['LOCATION']."
SUMMARY:".$params['SUMMARY']."
SEQUENCE:0
UID:1
CATEGORIES:".$params['CATEGORIES']."
DESCRIPTION:".$DESCRIPTION."
END:VEVENT
END:VCALENDAR
";

	// GET LENGTH, AND STORE DATA TO OUR SERVER (OR DATA BASE)
    $len = strlen($event);
    $chk = file_put_contents($filename, $event);
    
    // TEST FOR SUCCESSFUL STORAGE
	if ($len!=$chk) die("LENGTH MISMATCH");
}
echo '<a href="'.$filename.'" target="_blank">'.$params['linktext'].'</a>';

In the cal template

Code: Select all


{assign var=date_start value=$event.event_date_start|replace:" ":"-"}
{assign var=EName value=$event.event_title|replace:"/":""|replace:" ":"-"|replace:"’":""}
{assign var=Name value="$date_start-$EName"}
{assign var=DTSTART value=$date_start|date_format:"%Y%m%dT%H%M%S"}
{assign var=DTEND value=$event.event_date_end|date_format:"%Y%m%dT%H%M%S"}
{assign var=Thesummary value=$event.event_summary}
{assign var=title value=$event.event_title"}
{assign var=SUMMARY value="$title-$Thesummary"}
{assign var=CATEGORIES value=""}
{assign var=LOCATION value=""}
{assign var=DESCRIPTION value=$event.event_details|strip_tags}

{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Calendar" />'}

{addEvent EventName="$Name" DTSTART=$DTSTART DTEND=$DTEND SUMMARY=$SUMMARY LOCATION=$LOCATION CATEGORIES=$CATEGORIES DESCRIPTION=$DESCRIPTION linktext=$altFront$AltName$AltBack}




now if you don't want the image... change

Code: Select all

{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Calendar" />'}



to

Code: Select all

{assign var=altFront value=''}
{assign var=AltBack value=''}



I will be cleaning this out more later... but.... simple dirty and gets the job done... you can view the output here,


http://98.129.105.20/

which will be come

http://www.northcentralidaho.org


Cheers
Jeremy Bass

Please let me know
what programs you tried it in, any errors, etc... I have Outlook 2000 and 2007 confirmed working... but it should work with much more...


Compatible and tested with:
  • Outlook 2000
  • Outlook 2007
  • Lightning 0.9   (for Thunderbird)
  • Sunbird


Note:
You may want to add this to your .htaccess or equal since there is iis users out there

Code: Select all

AddType application/octet-stream .ics


You need to force the download since some browsers are not well debate who cares get the job done... ;) see ... I got your back

also change your time zone.. I'm sure you all are not in US-Pacific

TZID:US-Pacific

and adjust this to match

TZOFFSETFROM:-0700
TZOFFSETTO:-0800
.
.
.
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
Last edited by JeremyBASS on Sun Jan 17, 2010 6:59 pm, edited 1 time in total.
JeremyBASS

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by JeremyBASS »

Well just an update... I made a module for this..

http://dev.cmsmadesimple.org/projects/ical

just add {cms_module module=iCal Mode="default" Btn="TestSET"} to your CGCalendar template... or anywhere... it don't need a module either...

Cheers
Jeremy
smansman
Forum Members
Forum Members
Posts: 28
Joined: Wed Apr 23, 2008 6:08 pm

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by smansman »

thanks for sharing very interesting
User avatar
suthex
New Member
New Member
Posts: 8
Joined: Mon Jul 20, 2009 11:00 pm
Location: Proudly Sitting in a Chair somewhere in Canada

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by suthex »

Installing your module, notice it has a pre-req of CMSms 1.6.5 ... are there special CMSms features that require such a "current" version, or will I get away with installing into 1.6 ??


Doug
We've been building kick-ass online sites using CMS Made Simple since 2008.
JeremyBASS

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by JeremyBASS »

oh, I think nothing would stop it, but FWIW 1.6.6 is very stable, and it's super easy to upgrade to.  but, no I think it should work just fine, you have to change the version in the file by hand to override. Cheers -Jeremy
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by Gregor »

Just playing around with the module and before importing the file in my agenda.... Is there a way to change the time zone to Europe?

This is the content of the agenda (cmsms v.1.7)
BEGIN:VCALENDAR
PRODID:-//NCITA//northcentralidaho.org 1.0//EN
VERSION:1.0
BEGIN:VEVENT
BEGIN:VTIMEZONE
TZID:US-Central
LAST-MODIFIED:19870101T000000Z
TZURL:http://zones.stds_r_us.net/tz/US-Central
BEGIN:STANDARD
DTSTART:20071104T020000
RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=11
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:20070311T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=3
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
END:DAYLIGHT
END:VTIMEZONE
URL:http://www.ontwikkel.jwvdmeene.nl
ORGANIZER:MAILTO:
DTSTART;TZID=US-Central:
DTEND;TZID=US-Central:
LOCATION:
SUMMARY:
SEQUENCE:0
UID:1
CATEGORIES:
DESCRIPTION:
END:VEVENT
END:VCALENDAR
I'm missing a number of dates. Any idea on how to solve this? http://www.ontwikkel.jwvdmeene.nl/kalender/schoolkalender.html

Thnkx,
Gregor
JeremyBASS

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by JeremyBASS »

I'll see what I can do to put this to rest... may-be over the weekend.. Cheers -Jeremy
User avatar
Gregor
Power Poster
Power Poster
Posts: 1874
Joined: Thu Mar 23, 2006 9:25 am
Location: The Netherlands

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by Gregor »

Any luck yet Jeremy?

Gregor
JeremyBASS

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by JeremyBASS »

oh sorry no.. Sadly I'm so upside down it's killing me lol.. I will get to it I just don't know when.. I'm trying to make ends meet and that is not going all that well either lol.. I'll get to it I promise it's on my list.. Cheers -Jeremy
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am
Location: Berlin

Re: iCalendar output for CGcalendar (adding event to user's personal calendar)

Post by nicmare »

very interesting user interface of the module…Now i know why you will go to Geek Moot for Ajax/CMSms :D :D
but is there maybe an update for european (->germany->berlin) users? :D
i used to use the ical url from cgcalendar but i got troubles with it. and now i am looking for something more reliable…
thanks!
Post Reply

Return to “Tips and Tricks”