[TYPO3-project-formidable] Renderlet:Lister - Export as CSV, RSS, XML ...

Benjamin Fischer mailbox at typedown.com
Tue Apr 29 15:27:15 CEST 2008


Hi Luc,

Thanks again for your code example - I tried it and it worked very
well to export CSV data from a renderlet:lister.

To suit my needs I have changed a few things:

$this->aODataSources["liste_contact"]->_fetchData();
to
$aData = $this->aORenderlets["mylister"]->_fetchData();

to get only the current visible data rows to save performance and get
the result of the current search.
This really is an issue as the database already has around 75 000 entries.

comma separation instead of ;

a little feature to format a certain field (datetime) to legible date.

I have posted the code modification here http://pastebin.com/f3988af7a
if someone is interested.

You were right with the pandora's box comparison - already thought
about another static export format: VCF to export Userdata in the
vCard-Format ;-)


All the best, A+

Benjamin

On Mon, Apr 28, 2008 at 5:06 PM, Luc Muller <l.mul-nospam-ler at ameos.com> wrote:
> Ho ho ho...
>
>  well.... hmmm.... we already think about this...
>
>  it's true that being able to chose the output format of formidable would
>  be cool...
>  in another hand, those kind of ideas sounds like "ooopsss I think I've
>  just openend the pandora's box....".
>
>  Well, especially for you... (and all the other Formidable users)
>
>  here's something I've made a few days ago.
>
>  assuming you got a datasource "mydatasource"
>
>  you can create a button like this :
>
>  <renderlet:BUTTON name="getcsv" label="Download CSV DATA">
>             <onclick runat="server" when="end" >
>                 <userobj>
>                     <php><![CDATA[
>
>                         $aData =
>  $this->aODataSources["liste_contact"]->_fetchData();
>
>                         $aBodyContent = array();
>                         foreach($aData["results"] as $key=>$val){
>                             $aHeader = array();
>                             $aBodyContent[$key] = array();
>                            foreach($val as $key=>$val){
>                                 $aHeader[] = $cle;
>                                 $valeur = str_replace(";","",$valeur);
>                                 $aBodyContent[$key][$cle] = $valeur;
>                             }
>                             $aBodyContent[$key] =
>  implode(";",$aBodyContent[$key]);
>                         }
>
>  //                        debug($aHeader,"Header");
>  //                        debug($aBodyContent,"Content");
>
>                         $sHeader = implode(";",$aHeader)."\n";
>                         $sBodyContent = implode("\n",$aBodyContent);
>
>  //                        debug($sHeader,"header");
>  //                        debug($sBodyContent,"Content");
>
>                         $sCsv = $sHeader.$sBodyContent;
>
>                         $sCsv = utf8_decode($sCsv);
>
>                         //debug($sCsv,"Csv");
>
>                         $sFileName = md5($sCsv).".csv";
>
>
>  t3lib_div::writeFileToTypo3tempDir(PATH_site."typo3temp/csv/".$sFileName,$sCsv);
>
>
>  $this->forceDownload(PATH_site."typo3temp/csv/".$sFileName,"liste.csv");
>
>                         return false;
>
>                     ]]></php>
>                 </userobj>
>             </onclick>
>         </renderlet:BUTTON>
>
>  This SHOULD create a csv download button to download all the data from
>  the datasource in the current state of search.
>  as I removed some piece of code (formatting and so on...) right in my
>  mailer, the script may not work from scratch, but the idea is here.
>
>  Hope this will help you.
>
>  Luc Muller
>
>  Benjamin Fischer a écrit :
>
> > Hello again at formidable,
>  >
>  > I am currently working on a formidable frontend to display tracking
>  > data of user interaction on an image database. Actions like Login,
>  > Upload, Download, Preview, Zip and other actions are logged in MySQL
>  > and later formated and displayed with a formidable Renderlet:Lister
>  > bound to a searchform. This works very well and the feature ist used
>  > frequently by the administrators of the image database.
>  >
>  > To have an even more powerful system it would be great if the users
>  > could export the current searchresult of the Renderlet:Lister in
>  > another format like CSV to save it on their local disks. Another much
>  > asked for feature would be the generation of RSS Feeds from
>  > Renderlet:Lister results. These feeds might have their params send via
>  > get params i.e. ?action=upload&user=664&type=rss to have an RSS Feed
>  > of all recent uploads of user 664.
>  >
>  > Do you think this could be possible with formidable - or maybe would
>  > it be possible using special "templates" for other datatypes like CSV,
>  > RSS, XML or even others like ICS oder TXT.
>  >
>  > Thank you again for formidable, all the best,
>  >
>  > Benjamin
>  >
>  >
>
>
>  --
>
>  *Luc Muller*
>  /Web Developper/
>  /Formidable - Rapid Application Developpement Framework for Typo3
>  <http://formidable.typo3.ug>/
>  /Typo3 Ameos <http://www.ameos.com>/


More information about the TYPO3-project-formidable mailing list