Posted by chaps2 on May 8, 2008 at 9:20am
Jump to:
| Project: | AJAX Views |
| Version: | 5.x-1.4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | febbraro |
| Status: | closed (fixed) |
Issue Summary
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
#1
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.
#2
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
#3
this function:
<?phpfunction _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:
<?php
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).
#4
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.
#5
Hello,
I have tested it with the following arguments list (in that order)
and the block is called with this:
<?php$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=0and it works.
From my point of view, this is enough. The only problem in collecting the arguments is that
if ($argument['type'] == 'ajax_response') { .../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.
#6
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.
#7