0

Trying to get views data export to save file with selected token from exposed filter

In the settings I can see this explanation:

%exposed == effective exposed filters, like filter1_foo-filter2_bar

So I tried this:

%[field_industry_type].csv                    
%field_industry_type.csv
%field_industry_type_tid.csv

But can't get nothing to work, what I'm trying to do is use a field filter as .csv name, one of the filter types is industry, so if industry is "relocation" I would like the file to save like this:

relocation.csv

Maybe my token syntax is wrong?

enter image description here

enter image description here

enter image description here

1 Answer 1

0

%exposed itself combination of the number of exposed filters you have on your view. When you save file name only with %exposed.csv it should generate file name as per your request would be like "industry_relocation.csv".

So, %exposed will generate based on "FIELDIDENTIFIERNAME_VALUE-ANOTHERFIELD_VALUE".

To generate a custom file name you should use hook_views_pre_build() function. You can find examples here: https://www.drupal.org/project/views_data_export/issues/1288612

6
  • "When you save file name only with %exposed.csv it should generate file name as per your request would be like "industry_relocation.csv" ---- That doesn't work
    – yvesguy
    Commented Apr 30, 2019 at 8:33
  • Your data export view must have exposed filters enabled which you have added in the page. Once you enable, use filename %exposed.csv should work. Commented May 1, 2019 at 0:16
  • For some reason it doesn't work, I don't think %exposed.csv is the proper syntax. What do they mean by this: "effective exposed filters, like filter1_foo-filter2_bar" separate filters with underscore?
    – yvesguy
    Commented May 1, 2019 at 1:42
  • "effective exposed filters, like filter1_foo-filter2_bar" here is the explaination based on my understanding. filter1_foo: filter1 = Exposed filter 1 field name where foo = Exposed filter 1 field value filter2_bar: filter2 = Exposed filter 2 field name where bar = Exposed filter 2 field value Commented May 1, 2019 at 2:22
  • Thanks Kirt, but still I don't understand...let's say the exposed filter is called "industry" and the value is "dental", I want the file to be saved as dental.csv, what would be the exact syntax or verbose to put in there?
    – yvesguy
    Commented May 10, 2019 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.