Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm working on a similar example for my own project so if I discover a resolution I'll update this thread with any results.</p> <p>There's a helpful article on the contextSwitch view helper here (maltblue) which explains the helper in more depth.</p> <p><a href="http://www.maltblue.com/2010/09/software-development/php/frameworks/zend-framework/json-xml-rss-csv-its-all-a-contextswitch-away" rel="nofollow">contextswitch view helper</a></p> <p>I managed to export to csv ok in the end by putting the headers in the controller action directly as follows.</p> <p>in my action...</p> <pre><code>//create the csv file header and filename based on the action name $actionName = $this-&gt;getRequest()-&gt;getActionName(); new Admin_Model_Resource_csvFileHeader( $actionName ); </code></pre> <p>rest of code here to get the data to pass to the view file...</p> <p>the admin model resource is as follows so it can be used by any controller acton...</p> <pre><code>class Admin_Model_Resource_csvFileHeader </code></pre> <p>{</p> <pre><code>private $_csvFileNameFromAction = null; /** * Create the first part of the csv file name from the action name * @param &lt;string&gt; $actionName - name of the controller action for the report */ public function __construct( $actionName ) { $this-&gt;_csvFileNameFromAction = $actionName; $this-&gt;generateCsvHeader(); } /** * Method is called direct from the constructor * to centralise and make consistent the csv file header * so it maximises code re-use * @return null - just generate the csv header */ public function generateCsvHeader() { $dateSuffix = date('d-m-Y', time()); $csvFileName = $this-&gt;_csvFileNameFromAction.'_'.$dateSuffix; header('Content-Type: text/x-csv; name="'.$csvFileName.'.csv"'); header('Content-Disposition: inline; filename="'.$csvFileName.'.csv"'); header('Pragma: public'); header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header('Content-Transfer-Encoding: none'); } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload