Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The default filename on Views Export uses view-%view.[extension]. This is a variation of the mostly discredited Hungarian notation.
Suggest just using %view.[extension] instead.
Comment | File | Size | Author |
---|---|---|---|
#8 | views_bonus-HEAD_filename_defaults.patch | 3.88 KB | dboulet |
Comments
Comment #1
neclimdulI haven't responded to this but I should comment and say I'm not ignoring this but I just haven't decided what the right answer is. Patches and discussion are welcome.
Comment #2
Aren Cambre CreditAttribution: Aren Cambre commentedI think %view.[extension] would be fine. What do you think?
Comment #3
broonDespite of the fact that I'd prefer Arens version, I'd like to have more options. For example I use the standard taxonomy_term view and would like the user to be able to download a file containing all stories for a given term. Instead of having the downloaded file named (view-)taxonomy_term.(doc|xls|...), I'd like to insert the argument as part of the title, for example given the term 'sport' the downloadable file should be called sport.doc or taxonomy_term-sport.doc (by using a pattern like %arg[0].[extension] or %view-%arg[0].[extension].
I figured the change in code should be in views_bonus_export.theme.inc within the function _views_bonus_export_shared_preprocess, but I don't have a clue, which variables are available in $vars.
Comment #4
broonWhile playing around a bit I came across following solution for my problem.
Changing line 93 in views_bonus_export.theme.inc from:
array('%view' => check_plain($view->name))
to
array('%view' => check_plain($view->name), '%arg0' => check_plain($view->args[0]))
makes %arg0 available in filename und uses the first argument passed to this view. Adding more argument vars is of course possible by adding more items to the above array.
Comment #5
Aren Cambre CreditAttribution: Aren Cambre commentedHow about tokens using the Token module?
Comment #6
broonSounds like a good idea as far as how much I know about the Token module which is, well kind of nothing. For now I have changed the relevant part in the filename function to the following, enabling all given arguments, the view name as well as the current date to be used in the filename:
So, in my case the doc file for the taxonomy term view of 'sport' uses the dynamic filename %view-%arg0_%date.doc which results in taxonomy_term-sport_20090807.doc.
Comment #7
neclimdulSorry to disrupt but lets make token support a different issue. This is distracting from whether we should ax the Hungarian notation used in the default file name.
Comment #8
dboulet CreditAttribution: dboulet commentedThis patch changes the file name defaults. Discussions on adding more replacement options can continue in the following threads:
#686348: Token support for file export
#411392: Variables in filenames
#702180: Use more tokens in file name
#732930: Ability to add current date to filename
Comment #9
dboulet CreditAttribution: dboulet commentedComment #10
doublejosh CreditAttribution: doublejosh commentedHow be the patch?
Comment #11
broonThe patch in #8 just removes the string "view-" from default file names. But dboulet provides links to other issues where some patches à la dboulet are to be found.
I actually applied the date and the token patches (combined them) and they work like a charm. ;) Thanks for that dboulet!