Enabling / Disabling alpha pager by arguments
| Project: | Views Alpha Pager |
| Version: | 5.x-1.4 |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Hi! I am using D5.7 with views & alpha pager 5.x-1.4.
I created a view to list all the nodes of my custom "people" content type.
And I am using alpha pager to group the view output sorting by second name.
The view provides a page, with teaser list, and I set the pager to alpha. My view URL is
/query/people/
The view also can take a NodeID as argument, and my arguments handling code set the view to type=node, if a nid is passed as arguments. By example:
/query/people/it/87
/query/people/en/87
if ($args[0] && is_numeric(arg(3))) {
$view->page_type = 'node';
$args[0] = arg(3);
$view->use_pager = FALSE;
}
if ($args[0] && !(arg(3))) {
$args[0]='';
}
return $args;My problem is that I DON'T want the pager, when showing a single node. How can I disable the aplha pager, in the arguments handling code? It seams that
$view->use_pager = FALSE;
does not work.
Can you hel me? Is it possible?
Thanks,
GP

#1
Hi...me again.
I was able to disable it only modifying the module code. And probably this is not very good. As it works for my purpose, but not in general. Here it is what I did:
function views_alpha_pager_views_pre_query(&$view) {
if (_views_alpha_pager_get_placement($view->vid)) {
$view->is_cacheable = FALSE;
}
if ($view->page_type == 'node') {$view->use_pager = FALSE;} // <----- MY ADD
}
function views_alpha_pager_views_query_alter(&$query, &$view, $summary, $level) {
$placement = _views_alpha_pager_get_placement($view->vid);
// mia patch start
$usoilpager = $view->use_pager; // <----- MY ADD
if (!$usoilpager) {return;} // <----- MY ADD
// mia patch end
if (!$placement) {
return;
}
And as I am newbie to drupal, probably it's very awful :)
So could you add a feature to allow disabling / enabling the alpha pager, from the inside of views arguments handling code?
Thank you,
GP
#2
I came across a similar problem, however I was embedding the view. I have solved it in a different fashion, which may not solve your problem. Either way, the issue still stands that we need to be able to disable the alpha pager on the fly.
_views_alpha_pager_get_placement was being passed $view->vid and checked the database directly to see if it should use the pager or not. This prevented the setting from being overridden.
My patch modifies views_alpha_pager_views_query_alter and _views_alpha_pager_get_placement by instead passing the full view, and having no placement set if $view->use_pager is 0.
This allows me to then do this:
<?php$viewPeople = views_get_view('people');
$viewPeople->use_pager = 0;
$listPeople = views_build_view('embed', $viewPeople, array($node->nid), FALSE, 0, 0, NULL);
?>
That way I can have a page "people" that will display all people with the alpha pager, and then embed the same 'people' view into other nodes, filtered by argument without the alpha pager.
In my site, people are faculty members which refer to a department page via node reference. The 'people' view page then displays all faculty members with an alpha pager, and I can embed the same view in department pages using the node reference as an argument to filter and display all faculty associated with the department.
#3
Patch looks close, but
isset($cache[$vid])should probably beisset($cache[$view->vid]). I haven't tested it, but other than this, it looks good. So if we get a couple of testers, I'll commit it.#4
Subscribing