Skip to content

Instantly share code, notes, and snippets.

@luistinygod
Created March 13, 2015 16:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luistinygod/cb10a23327db2bae0d3c to your computer and use it in GitHub Desktop.
Save luistinygod/cb10a23327db2bae0d3c to your computer and use it in GitHub Desktop.
GravityView DataTables: How to change the CSV file field separator
<?php
/**
* Change the field separator when exporting a DataTable view into a CSV file
* Replace MY_FIELD_SEPARATOR by the new separator character like '|' or ';'
*/
function my_gv_datatables_csv_export_separator( $config, $view_id ) {
if( empty( $config['tableTools']['aButtons'] ) ) {
return $config;
}
foreach ( $config['tableTools']['aButtons'] as &$button ) {
if( 'csv' == $button['sExtends'] ) {
$button['sFieldSeperator'] = 'MY_FIELD_SEPARATOR';
}
}
return $config;
}
add_filter( 'gravityview_datatables_js_options', 'my_gv_datatables_csv_export_separator', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment