简体   繁体   中英

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

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',

Sorry for your time. I find the solution. I miss a ',' and thats why it did not displayed the pager when adding the '#quantity' in the theme array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM