Ad Space
Ad Space

Hosting Geared For
your CMSMS needs

CMSMS ready Hosting

Hosting Starting at $15

  • • Hosted Mail
  • • Personal Control Panel
  • • CMSMS 1.8.1 tested
  • • Lightly packed servers
  • • Intrusion Detection
  • • URL monitored
  • • Custom solutions available

Order your hosting Now

CP Blogs

add iCalendar to CGCalendar

Posted by: Jeremy Bass
on Sep 28, 2009

Category:

Coding, Intermediate, Smarty, Presentation, CMS Made Simple

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

Ad Space

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


UDT:    addEvent
Code:



$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:

{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:
{assign var=altFront value='<img src="/images/cms/editbutton.png" alt="Add '}
{assign var=AltBack value=' To your Calendar" />'}




to

Code:
{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

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:
AddType application/octet-stream .ics 


You need to force the download since some browsers are not well debate who cares get the job done... Wink 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
Ad Space

Get Social With It

[+]

Add A Comment

[+]

Code in the picture:
Title:
Your Name(*):
Email:
Notify me of any further comments to this thread:
Website:
Comment(*):
 
Previous page: Hosting FAQ Next page: Experimental