Jump to content

Change how many page numbers to show between ellipses in pager


thetuningspoon
 Share

Recommended Posts

A client has requested that the pager always show the next page number when the total number of pages exceeds the numPageLinks. This is what it's showing right now when on Page 7:

Prev   1   ...   6   7   ...   24   Next

This is what they would like:

Prev   1   ...   6   7   8   ...   24   Next

I think it is a little more intuitive for some people to be able to click on the next page number rather than on the Next button.

I looked through the options and didn't see anything for this. I started looking through the code as well to see if I could hack it but I'm having trouble pinpointing where this determination is made.

Link to comment
Share on other sites

There's no special setting for the number of page links between the ellipses, but how many appear there is determined by the numPageLinks setting, which as I understand it should control how many extra page numbers appear in addition to the first and last page numbers.

So you'd expect that a numPageLinks setting of 3 would achieve what you want, but it seems buggy:

2019-07-09_102603.png.5adf9f36836e5aff946dd996a9ab8f85.png
Why is the current page the last number and not the middle number?

2019-07-09_102721.png.2611b4097431931ee3ea7a2c4bcdb79e.png
Why are there only two numbers here instead of three?

2019-07-09_103053.png.bc46703d5ea6c5e71b53d40521e46c94.png
Likewise here - why aren't there three numbers in addition to the first and last numbers?

Why does the second page look like this...
2019-07-09_102900.png.107ced5f4370dfedf60fd066d9cd79c6.png
...but the second to last page look like this...
2019-07-09_102922.png.9639d0e59de684724ac2f0c42590f8bb.png
?

If you want to have a go at fixing it the relevant code is in PagerNav::getPager().

  • Thanks 1
Link to comment
Share on other sites

  • 1 month later...

Hi @matjazp - I just tested with values of 2, 3, 4, and 5 and it works perfectly ?

A value of 1 or 0 should probably be ignored and replaced with 2 as the minimum.

Here is the link to the GitHub issue for this: https://github.com/processwire/processwire-issues/issues/969

Do you think you can submit this as a pull request?

Link to comment
Share on other sites

43 minutes ago, thetuningspoon said:

Just found one possible inconsistency here. On a pager with a numPageLinks value of 3 and 23 pages total (I think the total number is effecting it somehow), the fifth page shows 4 page links between the ellipses instead of 3.

Hm, I see 3:

image.png.1d7b1b025f38e496cd3f1162354260db.png

1 hour ago, thetuningspoon said:

Do you think you can submit this as a pull request?

I don't do PRs as they are not accepted. Ryan finds his way of fixing it. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...