Hi There,
I am trying to create a dynamically generated downloadable calendar. Users click a link on the page and all the dates that are associated with that page get rendered by a template in ical format and then pushed back to the user as an ".ics" file. There are six spaces inserted before the rendered text which prevent Google calendar recognizing it. Does anyone have any idea why the SS_HTTPRequest::send_file() function would put six spaces at the beginning of a file. Here is the code:
// Function to generate a calendar to display the key dates
public function calendar() {
// Get the future key dates
$keyDates = DataObject::get("KeyDate", "`KeyDate` > CURDATE() AND `GrantPageID` = " . $this->ID, "", "", '');
// Make the data available to the template
$info = array(
'KeyDates' => $keyDates
);
// Code for passing a file rendered with the ss template "Calendar"
// and passed back to the browser
$filename = $this->Title . "_" . date('Y') . ".ics";
$calendar = ltrim($this->customise($info)->renderWith(array('Calendar')));
return SS_HTTPRequest::send_file($calendar, $filename, "text/calendar");
}