Skip to content

Latest commit

ย 

History

History
61 lines (36 loc) ยท 2.28 KB

File metadata and controls

61 lines (36 loc) ยท 2.28 KB

๐Ÿ“ฅ Import / Export CSV (for Sym8)

Author: Twisted Interactive

Maintainer (Fork for Sym8): Tilo Schrรถder

Version: 1.2+ (compatible with Symphony CMS โ‰ฅ 2.84.0 & PHP 8.x)

This extension lets you:

  • Export entries of a section as a .csv file
  • Import entries from a .csv file โ€” as new entries, updates, or ignored rows

In the revamped Sym8 version, the import process has been significantly improved: All fields are now fully validated (required, min, max, pattern, validator, etc.). Invalid rows are skipped, and details are logged in the Symphony Log.

๐Ÿ›  Import drivers

Import and export functionality is handled by import drivers, located in the /drivers folder.

By default, the extension looks for a driver named ImportDriver_(fieldname) to handle each field. If no specific driver is found, it falls back to ImportDriver_default.

Example:

  • select field โ†’ ImportDriver_select
  • upload field โ†’ ImportDriver_upload

๐Ÿ“ฆ Included drivers

This fork includes drivers for:

  • Frontend Member Password (avoids double-MD5 hashing)
  • Select (handles multiple values via comma separation)
  • Selectbox Link and Reference Link (exports readable values)
  • Subsection Manager
  • Status fields
  • Upload (handles file paths and import)

โœ๏ธ Writing your own driver

If you're using a custom field type and the default driver doesn't fit, you can write your own driver. It's quite simple โ€” just take a look at ImportDriver_default.php or the included drivers.

๐Ÿ” import($value, $entry_id)

This function prepares a value from the CSV for storage in an entry.It should return an array $data, which will be passed to $entry->setData($field_id, $data).

๐Ÿ” export($data, $entry_id)

This function prepares the entry data for the CSV output. Return a readable string, e.g. comma-separated for multi-value fields.

๐Ÿ” scanDatabase($value)

Used when updating or ignoring entries based on a unique value. This function searches the database and returns the entry_id of a matching record, or null if no match was found.

๐Ÿ’ก Features & Notes

The import process performs full field validation (as defined by your section schema)

  • Invalid rows are not saved
  • Errors are logged in the Symphony Log (/manifest/logs/main)
  • Large CSV files are processed in batches