Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.11
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Jun 2010 at 17:50 UTC
Updated:
21 Feb 2011 at 17:55 UTC
I'm trying to find the arguments set for my view in the theme layer and am not seeing them on the page? In the view preview (after saving) the four arguments I set up work fine and filter content, and show up in the display title. On the page for the display though, they're not getting set?
In views.inc pre_execute() I did a drupal_set_message($this->args) after $this->set_arguments(). I see the first argument but none of the others?? Am I going to run into trouble if custom work is rewriting the paths for these? What part of the view array would I use to set arguments in preprocess_views_view()?
Thanks for any help.
Comments
Comment #1
merlinofchaos commentedBefore I can answer this question, I have to know where the arguments are supposed to be coming from.
Comment #2
nicknickoli commentedThe arguments in the path to the view come from menu links or static content and, end in the form http://example.com/myview/my-category-term. What's unique is the category terms are rewritten for SEO in theme menu or theme breadcrumbs, so they don't necessarily match the normal path for the terms.
Shouldn't I still see everything split by "/" as args in the view preprocessor? What do you recommend as the best way to change arguments there??
Comment #3
merlinofchaos commentedWhen you're doing path rewriting, is it via the url_alias table or the custom_url_rewrite() hook? If so, Views is unable to see the originals and only sees the 'internal' path and has absolutely no visibility into the original URL (that being what the user visited).
Comment #4
nicknickoli commentedIt looks like we're only doing it occasionally, so Views or Panels picks up the first part of the path and the arguments get rewritten in php-argument code. The called function untidys the term and then calls get_path_alias(). On the plus side, it looks like args can get rewritten in theme_preprocess_views_view(). Yay! If I'm reading this right, I can check these params for the current display:
And then change arguments here:
$vars['view']->args[0,1....] = 'somthing'Thanks for help walking through this.
Comment #5
dawehnerSo this is fixed
Comment #7
Hardcode commentedI'm trying to set a parameter in theme_preprocess_views_view by $vars['view']->args[0] = 123, but setting this doesn't really change the view output as this parameter is set on numerous places in $vars, including $vars['view']->build_info['substitutions']['%1'] and many others. Even after changing it in this one the view is still not changed. Is there any way to set this new parameter for the whole thing at once?
Comment #8
nicknickoli commentedThe code I was using has changed since this post, but it did work for me using the 'args' parameter of the view hash. The two places this should work are at
theme_preprocess_views_view(&$variables){}andhook_views_prerender($variables){}. Did you try either of those and flush caches? These links might be helpful-http://drupal.org/node/246742
http://drupal.org/node/343533
http://drupal.org/node/342132
Comment #9
Hardcode commentedIf you do a print_r($variables) in theme_preprocess_views_view(&$variables) you can count the parameter being used in 11 instances. I found it intriguing for $variables to be so much defined even on preprocessing. But that wouldn't be much of a problem if $variables wouldn't have much nested data with objects. I will check for a views function that maybe builds $variables up and see what it does, but I suspect I will have to change the arguments in $variables manually. $args are not even visible in theme_preprocess_views_view even when being globaled. Let me also demonstrate what I'm trying to do. I attempt to use cleaned taxonomy terms as an argument.
Comment #10
Cristobal Wetzig commentedIf I understand you correctly the code above does not work? I tried something similar and it did not work. Did you find a solution?