Closed (fixed)
Project:
Views data export
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Sep 2011 at 09:27 UTC
Updated:
21 Apr 2017 at 11:36 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
R.Hendel commentedIt would be fantastic, if there would be an option to use also arguments in the file name.
Comment #2
ultimikeSee this comment for the proper way to do this.
-mike
Comment #3
xurizaemonComment #5
aniket.mohite88 commentedHi,
Its a good point mentioned here in this comment.
I have used the below method to generate static or dynamic file-names while exporting.
--------------------------------------------------------------------------------------------
STATIC FILENAME
Step-1: Setting for the exported file
Step-2: Select "provide as file" & mention a filename
Step-3: Choose from replacement pattern tokens
--------------------------------------------------------------------------------------------
DYNAMIC FILENAME
To have a custom dynamic file name, you have to use the hook_views_pre_build(&$view) hook in your custom module.
You can have your custom calculations or get data from exposed filters & change the file-name dynamically using -
$view->display_handler->options['style_options']['filename'] = $file;
NOTE- Since you are altering the file-name dynamically, you have to first mention a static file-name as mentioned in above section.
example usage -
The above code will work & alter the file-name every time a filter is applied (filter value is changed).
Hope this helps.
Regards,
Aniket Mohite
Comment #6
arunkumarkThanks for comment #5 for dynamic file name change by coding.
The below code helps to change the file name in hook_views_post_execute().
The dynamic file name needs to pass for the argument.
$view->style_plugin->options['filename'] = 'NEW_FILENAME' . $nid;