Clean URL Alpha Pager
beekerstudios - July 11, 2007 - 20:16
| Project: | Views Alpha Pager |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
Instead of this: ?apage=U
I want this: /alpha-index/u

#1
it will be great!!!!
#2
If the view uses views arguments, clean-urls has the potential for breaking the view. I'm thinking about the best way to make this an option (with the default to be non-clean-urls).
#3
Attached is one implementation that uses a global setting. I'd like to compare this with an implemetnation that uses per view setting.
#4
Does this only modify the alpha pager module? Or does it affect other modules? I don't currently have any arguments, just filters. Is there potential for working around being able to use arguments.
[unrelated to alpha pager]
Also just out of curiosity how are you hooking onto the url's, even for the ?this=that url's. I have a need for this type of per node functionality in a section of my website, but can't seem to figure out how to do something like that. Please e-mail me if you have any pointers on this sort of thing.
#5
This patch is only for alpha pager. I haven't committed it yet, because of my comments above. I'd like to try another implementation and see how it looks.
I don't think there's going to be a way to work-around the arguments restriction because arguments can be optional. Figuring out which views arguments are optional or not, is difficult if not impossible.
If you'd like to know how something is done, my only suggestion is to look at the code.
#6
This works great for me, only caveat is that it seems to slap the clean URL at the end of the first url "directory".
For instance, I have been organizing any tools that I have implemented at /search/ so I had my alpha_pager at /search/alpha-index/
So it should be doing this:
/search/alpha-index/A
But it's doing this:
/search/A
Which is kind of funky.
For this particular scenario I really don't care, but when I want to use this pager for other sections and I want to bury it under a url structure it's not going to work.
For instance:
/about/news/article-index/A
Thanks for the response and dedicating some time to this.
#7
That's a problem with the patch. I'll need to rework it for that case.
#8
I also need the clean urls feature because of a redirection to an alpha pager view, and Drupal url-encodes the question marks and the equal sign of that url which in turn alpha pager is not designed to handle.
I ran into the same problem as "beekerstudios" in comment #6. Here are some suggestions how to fix it with the patch from comment #3 applied (I'm quite new to Drupal coding, so improvements are more than welcome).
First make sure the generated links inside the function views_alpha_pager_views_query_alter don't chop off the last entry:
<?phpif (isset($view->alpha_pager_link)) {
$link = $view->alpha_pager_link;
}
elseif (_views_alpha_pager_clean_url()) {
//change gm July 13, 2008: extract root url from views since it can contain slashes
if($view->url){
$link = array('href' => $view->url);
} //end change gm July 13, 2008
else {
$url = explode('/', $_GET['q']);
if (count($url) > 1) {
array_pop($url);
}
$link = array('href' => implode('/', $url));
}
}
?>
Next, make sure to extract the last parameter in the function views_alpha_pager_views_query_alter if clean urls have been enabled:
<?phpif (_views_alpha_pager_clean_url()) {
//change gm July 13, 2008: get the last parameter
//$arg = arg(1);
$args = explode('/',$_GET['q']);
$arg = $args[count($args)-1];
}
else {
$arg = isset($_GET['apage']) ? $_GET['apage'] : '';
}
$apage = substr($arg, 0, 1);
?>
The code above has not been tested with filters, and view parameters won't work.
If one were to use view->url to chop off the first part of $_GET['q'] and use the next parameter for alpha pager, then wouldn't it be possible to also treat parameters?
Or as an alternative, have one parameter called apage like in this example:
views/addresses/apage/B/xls
In theory at least, the clean urls could be made to work nicely with parameters.
#9
Seems like this issues has crept back into the module. Not sure if there is an issue with the module, or with the way I have the view setup. I just upgraded my drupal install to the latest, I will check those lines to see if the changes noted in the patch are present or not.
#10
I'm also quite interested on this. Are there any news?
#11
I'm also quite interested on this. Are there any news?