Philipp Kamps wrote:
> Hi,
>
> my goal is to allow my users to download a CSV export from my web
> application.
>
> In a pure PHP application I would do following:
>
> |// We'll be outputting a PDF
> header('Content-type: text/csv');
>
> // It will be called downloaded.pdf
> header('Content-Disposition: attachment; filename="export.csv"');
>
> |What would be a good way to do it with the MVC component?
>
> Here is what I tried so far:
>
> class ReportsExportView extends ezcMvcView
> {
>
> function createResponse()
> {
> $resultBody = 'csv content';
>
> $result = $this->result;
>
> // set $result->status ???
>
> $return = new ezcMvcResponse( $result->status, $result->date,
> $result->generator, $result->cache, $result->cookies,
> $result->content, $resultBody );
>
> // set $return->status ???
$content = new ezcMvcResultContent(); // see MvcTools/src/structs
$content->type = 'text/cvs';
// other properties can be set like charset, language, encoding
// but it seems it does not handle Content-Disposition: attachment
$return->content = $content;
> return $return;
> }
>
> // Have to implement a dummy method :(
> function createZones( $layout )
> {
> return array();
> }
> }
>
> So I override "createResponse" in my View class. But I don't know what
> status
> to set or how to change ezcMvcResponse object to set a custom header info.
>
> Can you help me here or point me to the documentation that will help me.
> Also
> let me know if my approach is completely wrong :)
>
> My Feedback:
>
> For an abstract class, "ezcMvcView" seems to be too concrete. It
> contains logic to
> work with the zones concept.
>
> Would it make sense to have an example class to handle custom response
> headers?
>
> Regards,
> Philipp
>
--
Alexandru Stanoi
System Developer
eZ Systems | http://ez.no
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components