heimrichhannot/contao-exporter

A backend module for exporting any contao entity to file.

4.2.5 2018-09-11 12:18 UTC

README

A module for exporting any contao entity.

alt myModulePreview

Export config preview

Features

  • export an entity list in the backend
  • export of entities in the frontend
  • currently supported file types:
    • csv
    • xls
    • pdf
    • zip (media file export as zip)

Classes

Hooks

Technical instruction

Backend export

Step 1

Define your global operation in your entity's dca as follows:

'global_operations' => array
(
    'export_csv' => \HeimrichHannot\Exporter\ModuleExporter::getGlobalOperation('export_csv',
                 $GLOBALS['TL_LANG']['MSC']['export_csv'],
                 'system/modules/exporter/assets/img/icon_export.png')
),

Step 2

Add your backend module in your entity's config.php as follows:

$GLOBALS['BE_MOD']['mygroup'] = array
(
    'export_csv' => \HeimrichHannot\Exporter\ModuleExporter::getBackendModule()
),

Step 3

Create a configuration for your export by using the exporter's backend module (group devtools).

Frontend

You can use frontendedit or formhybrid_list in order to easily create a module for manipulating your entities in the frontend. It already contains a function to export entities after submission!

Step 1

Create a configuration for your export by using the exporter's backend module (group devtools).

Step 2

Add the following code to your module in order to your module:

ModuleExporter::export($objConfig, $objEntity, $arrFields);

If you add $arrFields, this array will be iteratd automatically in your template. Alternatively you can print every entity's property using $this in the template.