Hi,
I've got some data on a page i'd like to create a button so the user can save as a CSV file.
Does anyone have any pointers how i might go about that?
Thanks
Grant
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Hi,
I've got some data on a page i'd like to create a button so the user can save as a CSV file.
Does anyone have any pointers how i might go about that?
Thanks
Grant
If you add your DataObjects for your pages and any associated DataObjects to a ModelAdmin then a button is automatically scaffolded to export to csv based on the summary fields (but is easily overridden to return a different set of fields).
If that isn't how you'd like to present it you can always just use the same code to create the button elsewhere
Hi swaiba,
Is that more in the CMS, as i want it on the page the user is on in the front end.
Thanks
Grant
Don't know if you've cracked this one yet. If not, if you do
$data = DataObjectSet::toNestedArray();
I would have thought you can use fputcsv http://php.net/manual/en/function.fputcsv.php