21493 Posts in 5784 Topics by 2622 members
General Questions
SilverStripe Forums » General Questions » SS_HTTPRequest::send_file puts spaces in front of text
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 165 Views |
-
SS_HTTPRequest::send_file puts spaces in front of text

19 November 2012 at 4:56pm
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");
}
| 165 Views | ||
|
Page:
1
|
Go to Top |

