[SOLVED] Issue with CSV export, with a placeholder in the pre-filter

Antares74

Member
Hi,
i've a issue to export my list in CSV format.
My list is pre-filtered through a pre-filter that takes a value via a placeholder.
The code in value field is:
Code:
$db = JFactory::getDBO();
$db->setQuery("select f.id_cespite_calcolo, f.nr_rata, f.id_calcolo
from (
   SELECT id_cespite_calcolo, max(nr_rata) as ratamassima
FROM `qiwyk_cck_store_form_calcoli`
where data_ammortamento <= '{___data_ammortamento}'
group by id_cespite_calcolo
) as x inner join qiwyk_cck_store_form_calcoli as f on f.id_cespite_calcolo = x.id_cespite_calcolo and f.nr_rata = x.ratamassima

");
$db = $db->loadObjectList();
foreach ($db as $row)
    {
      $arr_id[$row->id_calcolo] = $row->id_calcolo;
    }
    $arr_id = implode(",",$arr_id);
return $arr_id;

I send {___data_ammortamento} through a form.
The code works fine, I visualize the list correctly, but if i try to export it to CSV I recive a message that inform me that there are 0 results...
If i try to set a fixed value to {___data_ammortamento} in the code (ex: 2016/08/26), export operation works fine.
It seems that, in the export operation, the placeholder is not considered.

Any help?
Thanks a lot
 
Hi,
yes i send through redirect plugin.
In attach settings:

thanks
 

Attachments

  • Screen Shot 2016-08-29 at 12.40.43.png
    Screen Shot 2016-08-29 at 12.40.43.png
    47.3 KB · Views: 158
  • Screen Shot 2016-08-29 at 12.44.42.png
    Screen Shot 2016-08-29 at 12.44.42.png
    44.8 KB · Views: 146
So just to be clear, the redirect takes you to a list, which filters correctly, then you use the "Export to CSV" menu on that list?

If so, then no, the query string that was there for the page load of the list, won't be present for the link we generate for the Export to CSV URL. We generate a specific URL for the CSV export, we don't blindly add everything from the query string of the page load of the list that CSV link is on.

However ... if I recall correctly, I added a feature a while back for someone with this specific issue ... if you look in the CSV options (List, Publishing, CSV), there is a "Custom QS" setting. The tooltip explains your exact scenario, "For instance, if you are pre-filtering your list on a query string value ..."

So I think adding ...

___data_ammortamento={___data_ammortamento}

... to that Custom QS should do it.

-- hugh
 
Hi Hugh,
thanks for your replay, Your assumption is correct: redirect to a list which filters correctly but when i try to export by menu on that list i retrive 0 results.
I try to set Custom QS as you indicated to me, unfortunately it does not work.
If i set a fixed value (___data_ammortamento=25) it exports data but if i use placeholder i retrive 0 results...
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top