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

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Before I can answer this question, I have to know where the arguments are supposed to be coming from.

nicknickoli’s picture

The 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??

merlinofchaos’s picture

When 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).

nicknickoli’s picture

It 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:

 $vars['display_id'];
$vars['name'];
$vars['view']->display_handler->get_link_display(); 

And then change arguments here: $vars['view']->args[0,1....] = 'somthing'
Thanks for help walking through this.

dawehner’s picture

Status: Postponed (maintainer needs more info) » Fixed

So this is fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Hardcode’s picture

Version: 6.x-2.7 » 6.x-2.11

I'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?

nicknickoli’s picture

The 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){} and hook_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

Hardcode’s picture

If 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.

function multiflex3_preprocess_views_view(&$vars) {
  if (isset($vars['view']->name) && $vars['view']->name=='my view') {
	module_load_include('inc', 'pathauto', 'pathauto');
	$result = db_query("SELECT tid, `name` FROM {term_data} WHERE vid='2'");

	$vars['view']->args[0] = 'new argument';
	$arg = pathauto_cleanstring($vars['view']->args[0]);
	while ($term = db_fetch_object($result))  {
	   if (pathauto_cleanstring($term->name)==$arg) {
			 $vars['view']->args[0] = $term->name;
			 return;
	   }
	}
  }
} 
Cristobal Wetzig’s picture

If I understand you correctly the code above does not work? I tried something similar and it did not work. Did you find a solution?