james6848
james6848

Reputation: 1667

Modify Drupal Views pagination to restrict shown page numbers

I have an image gallery within a Drupal site that uses the 'Image Gallery' module (funnily enough...). There is a standard 'Views' pagination system that breaks down the gallery pages into manageable chunks, and which at the same time restricts the number of page links shown (indicated by ellipses), e.g.:

<<first <previous ... 3 4 5 6 7 8 9 10 11 ... next> last>>

So at the moment there are always nine page links shown. Basically I want to find out how to modify this so there are (for example) only five links shown:

<<first <previous ... 6 7 8 9 10 ... next> last>>

I'm guessing there is some bit of PHP in the module's code that manages this, but I'm loathe to go fiddling about without knowing what I'm doing!

Cheers, James

Upvotes: 2

Views: 2854

Answers (3)

sharpcrayon
sharpcrayon

Reputation: 21

(Drupal 7) To do this without hacking core, copy the theme_pager function from pager.inc. Put it in your template.php file, replacing "theme" with your theme name, so the function name becomes exampleThemeName_pager, for example. Then set the $quantity variable equal to the number of pages you would like displayed.

Upvotes: 2

antoyo
antoyo

Reputation: 11923

you just have to overload theme_pager() in your theme, like this :

function your_module_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
    return theme_pager($tags, $limit, $element, $parameters, 5);
}

Upvotes: 6

Jeremy French
Jeremy French

Reputation: 12157

If you are happy with hacking core and making this a global change to your site the quickest way is to modify includes/pager.inc and change the default value of $quantity to be the number you want.

There is a proper way to do this as well using your own theme function, if I get a chance I'll post a how to for that too.

Upvotes: 4

Related Questions