Posted by Aren Cambre on July 1, 2009 at 1:02am
5 followers
| Project: | Views Bonus Pack |
| Version: | 6.x-1.x-dev |
| Component: | Views Export |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
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.
Comments
#1
I 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.
#2
I think %view.[extension] would be fine. What do you think?
#3
Despite 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.
#4
While 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.
#5
How about tokens using the Token module?
#6
Sounds 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:
$filename_options = array('%view' => check_plain($view->name), '%date' => date('Ymd',time()));$args = $view->args;
foreach ( $args AS $key => $val )
{
$filename_options['%arg'.$key] = check_plain($val);
}
$filename = strtr(
$vars['options']['filename'],
$filename_options
);
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.
#7
Sorry 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.
#8
This 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
#9
#10
How be the patch?
#11
The 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!