Great module, but I can't see why arguments are replaced with wildcards. Most of my views are pretty useless without their arguments. I had no problem changing _generate_ajax_url to suit but I'm curious as to why it's designed that way.

Comments

febbraro’s picture

I was having problems when not replacing with the wildcard that nothing was showing up. I was not really relying on arguments for the data, but I can absolutely see how the views would be useless without them. It was my next bridge to cross. Were you having problems when the wildcards were in inserted? Also how are you specufy arguments to the views in What changes did you make and do you think they are generally applicable? If so I would gladly accept a patch. Thanks for using, I hope it helps you.

chaps2’s picture

My quick fix was suited to the fact that I'm using views within panel panes so it's easy to specify the ajax argument explicitly. I just return the views->real_url from _generate_ajax_url.

Otherwise I suppose it would be quite easy to get the arguments using $views->args[$argument['position']] when generating the url and use wildcards for missing arguments only.

Andy

magoo’s picture

Category: feature » bug

this function:

function _generate_ajax_url($view) {
	$url .= "$view->url";
	foreach ($view->argument as $argument) {
		if($argument['type'] == 'ajax_response') {
			$url .= "/ajax";
		}
		else if ($argument['wildcard']) {
			$url .= '/' . $argument['wildcard'];
		}
		else {
			$url .= "/*";
		}
	}
	return url($url);
}

removes all the arguments.

As far as I understand, it replaces the arguments by either "*" or $argument['wildcard'] (configured wildcard). Never does it test the existence of the argument.

I replaced it with the following:

function _generate_ajax_url($view) {
	$url .= "$view->url";
	$i = 0;
	foreach ($view->argument as $argument) {

		if($argument['type'] == 'ajax_response') {
			$url .= "/ajax";
		}
		else if ($view->args[$i]){
			$url .= '/' . $view->args[$i];
		}
		else if ($argument['wildcard']) {
			$url .= '/' . $argument['wildcard'];
		}
		else {
			$url .= "/*";
		}
		$i++;
	}
	return url($url);
}

in order to copy the argument in the ajax call url.

I have it working with one argument (in addition to the AJAX pagination argument).

febbraro’s picture

Assigned: Unassigned » febbraro

hanks for digging into that. Also, have you had a chance to try it with more than one argument?

I will find some time soon to work this into a new release.

magoo’s picture

Hello,

I have tested it with the following arguments list (in that order)

  • Taxonomy: Term ID
  • AJAX Views: AJAX Selector
  • Node: Type

and the block is called with this:

$t_view = views_build_view('block', $view, Array($skill_term->tid, '', 'article'), false, false);

the resulting url is:

<base_url>/<name_of_the_page>/68/ajax/article?page=0

and it works.

From my point of view, this is enough. The only problem in collecting the arguments is that if ($argument['type'] == 'ajax_response') { ... must be handled first and exclusively because we don't want the user to put a custom value in place of /ajax. This may change in the future, if the module adds more functionalities using the argument to differentiate calls.

Sorry for not posting a patch but the windows workstation at work is not my friend.

febbraro’s picture

Magoo thanks for doing the leg work here. I have put your code in place and things look good from my perspective. I will commit this to CVS and create a new release.

Thanks again.

febbraro’s picture

Status: Active » Closed (fixed)