My app uses ical-like events and I'd like to make these events
available for subscription from Google Calendar, Apple iCal, etc. The
guide at http://www.365webapplications.com/2009/01/09/cakephp-calendar/
helped me set up iCalcreator as a Helper.
However I'm confused on use of a view template vs. element: from the
Cake doc, I would have expected to use a template that defines the
overall layout (in this case, it would be empty as iCalcreator's
render takes care of everything); then the view would create an
iCalcreator object from the data provided by the controller and render
it to $content_for_layout.
However, the 365webapplications approach invokes the controller action
via a requestAction in an element, the element then creates the
iCalcreator object renders it. No template is used. When I do this, I
find that the controller action gets called twice, and seems to get
cut off prematurely:
i.e. my controller and element (simplified):
controllers/events_controller.php:
helpers[] = 'ICal'; // pull in the i_cal helper
$this->Event->recursive = 0;// don't need associated data
$events = $this->Event->find('all');
// called via a requestAction?
if (isset($this->params['requested'])) {
echo "controllers/events_controller: requested";
return $events;
}
echo "controllers/events_controller, setting events";
$this->set('events', $events);
echo "controllers/events_controller, done";
}
}
?>
views/elements/events.ctp
";
$events = $this->requestAction('events/ical');
echo "views/elements/events.ctp 2";
$iCal->create();
echo "views/elements/events.ctp 3";
foreach($events as $e)
{
$iCal->addEvent(
$e['Event']['datestart'],
$e['Event']['dateend'],
$e['Event']['summary'],
$e['Event']['description']
);
}
$iCal->render();
echo "views/elements/events.ctp 4";
?>
views/events/ical.ctp:
";
//echo $this->element('events', array('cache'=>'+1 hour'));
echo $this->element('events');
echo "views/events/ical.ctp end";
?>
Now, when I call the action, I get:
controllers/events_controller, setting events
controllers/events_controller, done
views/events/ical.ctp start
views/elements/events.ctp 1
controllers/events_controller: requested
views/elements/events.ctp 2
views/elements/events.ctp 3
render>
BEGIN:VCALENDAR METHOD:PUBLISH ... :VEVENT END:VCALENDAR
element('events');'
in the view>
Is the above the best way to output non-HTML?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---