Skip to content

Instantly share code, notes, and snippets.

@ChVuagniaux
Last active April 2, 2019 10:09
Show Gist options
  • Save ChVuagniaux/68d6203d2463f315e5bd5ac77b5fab17 to your computer and use it in GitHub Desktop.
Save ChVuagniaux/68d6203d2463f315e5bd5ac77b5fab17 to your computer and use it in GitHub Desktop.
Make October Import/Export feature compatible with Excel CSV (;) easily for your ends users
<?php namespace Your\Plugin;
use Event;
use System\Classes\PluginBase;
class Plugin extends PluginBase
{
// [...]
/**
* Boot method, called right before the request route.
*/
public function boot()
{
// Import form
Event::listen('system.extendConfigFile', function ($publicFile, $config) {
if ($publicFile !== '/modules/backend/behaviors/importexportcontroller/partials/fields_import.yaml') {
return null;
}
array_set($config, 'fields.format_preset.default', 'custom');
array_set($config, 'fields.format_delimiter.default', ';');
array_set($config, 'fields.format_preset.cssClass', 'hidden');
array_set($config, 'fields.format_delimiter.cssClass', 'hidden');
array_set($config, 'fields.format_enclosure.cssClass', 'hidden');
array_set($config, 'fields.format_escape.cssClass', 'hidden');
array_set($config, 'fields.format_encoding.cssClass', 'hidden');
array_set($config, 'fields.first_row_titles.cssClass', 'hidden');
return $config;
});
// Export form
Event::listen('system.extendConfigFile', function ($publicFile, $config) {
if ($publicFile !== '/modules/backend/behaviors/importexportcontroller/partials/fields_export.yaml') {
return null;
}
array_set($config, 'fields.format_preset.default', 'custom');
array_set($config, 'fields.format_delimiter.default', ';');
array_set($config, 'fields.format_preset.cssClass', 'hidden');
array_set($config, 'fields.format_delimiter.cssClass', 'hidden');
array_set($config, 'fields.format_enclosure.cssClass', 'hidden');
array_set($config, 'fields.format_escape.cssClass', 'hidden');
array_set($config, 'fields.step1_section.hidden', true);
array_set($config, 'fields.step2_section.label', 'Select columns to export');
// array_set($config, 'fields.export_columns.cssClass', 'hidden'); // uncomment this line if you don't want to choose columns
return $config;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment