+function ~file_name~_csv_download() {
+ require_once(__DIR__.'/'.'inc/wfpl/csv.php');
+ $rows = db_get_rows('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'order by id');
+ $fields = explode(',', 'id,'.~file_name upper~_DB_FIELDS);
+ $header = array();
+ foreach ($fields as $field) {
+ if (isset($GLOBALS['~file_name~_field_to_caption'][$field])) {
+ $header[] = $GLOBALS['~file_name~_field_to_caption'][$field];
+ } else {
+ $header[] = $field;
+ }
+ }
+ array_unshift($rows, $header);
+ array2d_to_csv_download($rows, '~file_name~.csv');
+}
+