Whilst the $response is not available in the Helper, it is available on the 
View class, and the view class is available on any Helper via $this->_View.

Therefore, $this->_View->response->type('csv'); from inside any Helper 
method should do the trick, unless output has already commenced, and 
headers have already been written.

Regards
Reuben Helms

On Wednesday, 11 June 2014 08:49:58 UTC+10, gloop wrote:
>
> Hello i try to write an helper to create and download a CSV.
>
> Now i have the problem to set the type in the helper.
>
> I try:
>
> function renderHeaders() {
>     $response = new CakeResponse(array(
>        'type' => 'csv'
>     ));
>     $response->download($this->filename);
>     $response->send();
> }
>
> Now i can download the file, but it's always type "text/html".
>
> When i set in the controller $this->response->type('csv'); it works 
> correct.
>
> Is there a way to use the CakeResponse in the Helper?
>
> Kind Regards
> Steffen
>  
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to