0

Solving custom pager 10 only problem with views

by geshan

Recently in a project we were carrying out, we faced a problem, the custom pager drupal module had a serious bug, it did not show more than 10 nodes when a view used to render the nodes. The usage of view by default made the problem worse.

Problem

At d.o the problem was described as "If you are using Drupal 6, you must currently install the 6.x-1.x-dev version of Custom Pagers, as there is a serious bug in 6.x-1.10-beta1 (when used with Views, it only shows up to 10 items, no matter what)." , here in this node.

Non Obvious Solution

The problem had a non obvious solution we discovered with trial and error. The ray of hope was "Pager Node List" array for each custom pager which took array of Node ids to show the custom pager, so the round way solution was as follows:

  1. Create a view that will output all node ids of a particular node type.
  2. Got to the custom pager setting for that particular pager.
  3. Execute the view in "Pager Node List" php code section of the custom pager. It will override the view execution.
  4. You are done, now pager will show X no. of posts not depenedent on view.

Code to Execute

Below is the code to execute in your "Pager Node List" option for the custom pager.

 

$display_id = 'default'; //name of the display
$nids=array();
$view = views_get_view('view_name'); //name of the view, change to your name
$view->execute_display($display_id);
foreach ($view->result as $result) {
  $nids[] = $result->nid;
}

return $nids;

Do it as shown below:

The way to do it

Conclusion

Problems might have non obvious solutions so think out of the box :).

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options