MadHatter Posted December 17, 2014 Share Posted December 17, 2014 I've created a new tab that I'm planning to use to download a list of all the users currently signed up to my site. What I'd like to do is set it up so that when the tab is clicked a file is downloaded, there should be no extra page shown with a download link. My current issue is that when the file is output as an attachment the admin theme is still being rendered and appended to my file. This causes Microsoft Excel to fail loading the spreadsheet. If you view the Excel file in a text editor you can see the HTML for the admin page has been added after the spreadsheet contents. Is there a way to stop the admin theme form rendering from within an execute() fuction in a Process module? So far my solution has been to end the execute() function with die(), though I feel that this is not the ideal solution. I was hoping there was a command I could call to stop the admin theme from rendering (such as with CakePHP's $this->autoRender = false) so that the functionality I was looking for could be acheived. Has anyone else tried what I have been attempting? Link to comment Share on other sites More sharing options...
adrian Posted December 17, 2014 Share Posted December 17, 2014 I am also not sure if using die/exit is the only way, but it is what I used in my Table CSV Export/Import module: https://processwire.com/talk/topic/7905-profields-table-csv-importer-exporter/ - see the "Export as CSV" button at the bottom of the first screenshot. The one thing in that module that you might find useful in this module is the hidden iframe technique I used to make the download work without the need to open an extra page: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L191 Take a look at the JS file in that module to see how I am modifying the src of the iframe on the fly when the Export button is clicked: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.js#L6 Hopefully you might find something to copy, or maybe someone else will have a better idea! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now