eZ Community » Forums » Developer » Fetch and export to file
expandshrink

Fetch and export to file

Fetch and export to file

Monday 08 February 2010 6:10:23 pm - 4 replies

Hello,

I have a fetch operation that displays information a page (and using google.tpl I can get to all pages with the information)...

I would like to save all fetches to a file so it can be imported later by an external program...

How can this be done? Can some one point out a simmilar extension that could do such performance?

thanks

Monday 08 February 2010 7:33:28 pm

did you look at ggxmlview extension on projects.ez.no?

It has xml and json templates that can be used for this kind of export - either as is or as an example to create your own customizations...

Thursday 14 June 2012 4:38:57 pm

Hi,

I just tested Mr Giunta's extension. Works fine but does not make what I want... so I'll try to explain my problem.

I have a custom fetch to get some information from a custom table (inside my custom module).

I need something to export this fetch result to a CSV file. Well, I need something to save a file from my custom module invoking the "save" operation from a view (I guess...).

 

I believe it's a very simple operation but I cannot figure out how to do that.

Thank you.

Friday 15 June 2012 7:58:23 am

Hi Simone,

1. you have to create the content for your csv - this can be done by a ez tpl or in php code => at the end you have your content in variable $dataCsv

2. Now you have to send the $dataCsv to the browser with a header() command or you create a tempfile with name $tmpFileName and force a download of this file. Here is one solution (the code ist not tested but should work)

$dataCsv = 'column1;column2;column3';
$tmpFileName = 'var/cache/mytmpfile.csv';
 
eZFile::create( $tmpFileName, false, $dataCsv );
 
if ( !eZFile::download( $file ) )
    // do something if the download failed

Modified on Friday 15 June 2012 7:58:54 am by Felix Woldt

Friday 15 June 2012 12:55:33 pm

Quote from Felix Woldt :

Hi Simone,

1. you have to create the content for your csv - this can be done by a ez tpl or in php code => at the end you have your content in variable $dataCsv

2. Now you have to send the $dataCsv to the browser with a header() command or you create a tempfile with name $tmpFileName and force a download of this file. Here is one solution (the code ist not tested but should work)

$dataCsv = 'column1;column2;column3';
$tmpFileName = 'var/cache/mytmpfile.csv';
 
eZFile::create( $tmpFileName, false, $dataCsv );
 
if ( !eZFile::download( $file ) )
    // do something if the download failed

Thank you Felix, that's what I need!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu