Hi!

A school project of mine, written in Cake, contains a list of events.
So far the events are accessible as RSS feeds and on the web-site,
however, I thought that it would be cool to implement iCal output.

First, I tried to do it using RequestHandler (which I had just learned
to use yesterday), but it doesn't look like it supports iCal output.
So, I defined a layout,

------------------------------------------------------------------------------------------
<?php header('Content-type: text/calendar'); ?>

BEGIN:VCALENDAR

VERSION:2.0

X-WR-CALNAME:HTXEvent

X-WR-TIMEZONE:Europe/Copenhagen

CALSCALE:GREGORIAN

METHOD:PUBLISH

<?php echo $content_for_layout; ?>

END:VCALENDAR

------------------------------------------------------------------------------------------

I then made a calendar.ctp view,

------------------------------------------------------------------------------------------
<?php foreach ($events as $event){ ?>

BEGIN:VEVENT

DTSTART;VALUE=DATE:<?php echo date('Ymd', strtotime($event['Event']
['start'])); ?>

DTEND;VALUE=DATE:<?php echo date('Ymd', strtotime($event['Event']
['end'])); ?>

SUMMARY:<?php echo $event['Event']['title']; ?>



END:VEVENT

<?php } ?>

------------------------------------------------------------------------------------------

And defined the calendar function in my EventsController,

------------------------------------------------------------------------------------------
function calendar()
        {
                $this->layout = 'ical';

                $events = $this->paginate();

                if (isset($this->params['requested']))
                {
                        return $events;
                }

                $this->set('events', $events);
        }
------------------------------------------------------------------------------------------

The whole thing is very basic, reminds a lot of the old way of doing
RSS. However, would be cool if this could be implemented using
RequestAction, so do you guys have any suggestions to how that would
be done? Otherwise I'll let this act mail as a tutorial :)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to