Open Misco opened 5 years ago
@Misco Currently it is possible to filter the list from the exporter config, but the list filter in not evaluated. If you want to do a pull request, you are welcome.
I like to try it. Maybe you can give me some hints. In witch file i should work and how to get current filterselction, does it work with php only or some js needed?
onsubmit getDCAfilter foreach DCAfilter get table typ (is array?) foreach DCAfilter make sql AND statement depending on typ add DCAfilter query to the WHERE config query
thanks
You must give the filter somehow into the exporter class. But how to get them and how to utilize them, I don't know.
The data for the php speadsheet exporter is retrived in AbstractPhpSpreadsheetExporter::exportList
.
@koertho i have write an Javascript to add the current filter to the export button href:
jQuery(document).ready(function($){ var f = '' $('.tl_filter select').each(function(){ var v = $(this).val(); var n = $(this).attr('name'); if(v != 'tl_'+n){ f = f+'&'+n+'='+v; } }); var h = $('#tl_buttons .header_export_csv_entities').attr('href'); $('#tl_buttons .header_export_csv_entities').attr('href',h+f); });
Now it should be possible to get the values in the class or?
@koertho witch file is called when the button was clicked?
@koertho i did go trough the files
AbstractPhpSpreadsheetExporter.php:33 add second parameter with the GET´s (possible here?) AbstractExporter.php:253 add second Where clausel from second parameter
later add some checkbox to the config so if cann be used.
Thanks
@koertho it looks like its working so far. Doing more test and opimizing and report back
Its working pretty well, but its creativ ;-)
protected function doExport($entity = null, array $fields = []) { $DCAfilter = ''; $i = 0; foreach($_GET as $key => $value){ if($key == 'do' || $key == 'key' || $key == 'rt' || $key == 'ref'){} else{ if($i > 0){ $DCAfilter .= " AND "; } $DCAfilter .= $key." REGEXP '".$value."'"; $i++; } } return $this->exportList($this->getEntities($entity,$DCAfilter)); }
and
public function getEntities($pid,$DCAfilter) { ... $wheres[] .= html_entity_decode($DCAfilter);
if you like it, i add checkbox for if statement and get the js inside of the extension.
Otherwise looking forward to see your solution (maybe, if you like to do)
@Misco I would recommend you to do a pull request so we can see the code changes. For input variables like get and post, please do not use the global variables ($_GET), it is better to use the symfony request object or the old contao Input class. A checkbox to activate/deactivate the filter would be a good addition.
I would like to export the current filtered list (DCA Filter) and not always all. Is this allready possible? If not i would like to help, because i think its usefull.
Thanks