mareike
Returning Observer

Export data source as csv

Hey community,
is it possible to export a data set in FirstSpririt for example as csv file?

Thanks for hints!

0 Kudos
1 Reply
bojan_vujnovic
New Creator

Yes it is possible. You must create overview page in Page template(in properties tab, change extension from html to csv)

After that in html tab you create function to access data source. Something like this:

<CMS_FUNCTION name="contentSelect" resultname="fr_content">

  <CMS_PARAM name="schema" value="referenceNameSchema" />

  <QUERY entityType="referenceNameForTable"/>

</CMS_FUNCTION>$--

--$$CMS_TRIM(level:3)$

     $CMS_SET(set_header,["ID","Language","Other fields"])$

     $CMS_VALUE(set_header.toString(";"))$

          $CMS_FOR(for_item,fr_content)$

               $CMS_FOR(sv_lang, #global.project.languages)$

                   $CMS_SET(#global.language, sv_lang)$

                   $CMS_SET(set_values,[])$

                    $CMS_SET(void, set_values.add(if(!for_item.id.isEmpty,for_item.id,"null")))$

                   $CMS_SET(void, set_values.add(sv_lang))$

                    $CMS_SET(void,set_values.add(for_item.otherFields)$

                              $CMS_VALUE(set_values.toString(";"))$

               $CMS_END_FOR$

          $CMS_END_FOR$

$CMS_END_TRIM$

After this in Page content insert new page(page from page template).Open it and you get csv.

0 Kudos