Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heimrichhannot/contao-exporter
A backend module for export configurations
https://github.com/heimrichhannot/contao-exporter
Last synced: about 1 month ago
JSON representation
A backend module for export configurations
- Host: GitHub
- URL: https://github.com/heimrichhannot/contao-exporter
- Owner: heimrichhannot
- Created: 2015-11-11T14:20:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-11T12:18:28.000Z (over 6 years ago)
- Last Synced: 2024-04-03T09:03:33.000Z (9 months ago)
- Language: PHP
- Size: 187 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Exporter
A module for exporting any contao entity.
![alt myModulePreview](docs/screenshot.png)
*Export config preview*
## Features
- export an entity list in the backend
- export of entities in the frontend
- currently supported file types:
- csv
- xls
- zip (media file export as zip)### Classes
Name | Description
---- | -----------
CsvExporter | An exporter for writing entity instances into a CSV file
XlsExporter | An exporter for writing entity instances into an excel file (XLS)
MediaExporter | An exporter that combines all files referenced by the selected properties of an entity in one archive file (e.g. zip) preserving the folder structure
PdfExporter | An exporter for creating a pdf out of an entity### Hooks
Name | Arguments | Expected return value | Description
---- | --------- | --------------------- | -----------
exporter_modifyHeaderFields | $arrFields, $objExporter | $arrFields | Modify the header fields just before just before being written to file
exporter_modifyMediaFilename | $objFile, $strFieldname, $varFieldValue, $objMediaExporter | $objFile->path | Modify a filename just before added to the archive when using *MediaExporter* (also folder structure could be modified here)
exporter_modifyFilename | $strFilename, $objExporter | $strFilename | Modify the export filename
exporter_modifyFilePath | $strFilePath, $objExporter | $strFilePath | Modify the export file path
exporter_modifyFieldValue | $varValue, $strField, $arrRow, $intCol | $varValue | Modify the field values. Only available in PhpExcelExporter## 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](https://github.com/heimrichhannot/contao-frontendedit) or [formhybrid_list](https://github.com/heimrichhannot/contao-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.