Search code examples
drupaldrupal-7pager

Drupal 7 build pager


I am trying to build a pager in a node list. Here is a piece of my code : `$nodes = node_load_multiple($nids);

$current_page = pager_default_initialize(count($nodes), 12);

$chunks = array_chunk($nodes,12, TRUE);

$build['pager'] = array(
  '#theme'  => 'pager',
  '#quantity' => count($nodes),
  '#weight' => 100
);`

There is just a little problem with this : I have a lot of nodes and it displays (page : 1 2 3 4 5 6 7 8 9 etc to 150) What I actualy want is a pager like this (Page : 1 2 3 4 5 ...).

So the pager should not display 150 digits but only 5 with '...' at the end to show that there is more than 5 pages.

Thanks for your answers


Solution

  • You can override the theme_pager in your template file. Or you could register your own theme with hook_theme, create the theme function and pass the new theme name in the render array like '#theme' => 'my_pager',