Pager redundant "first" and "last" links.

Created on 15 July 2009, over 15 years ago
Updated 24 January 2025, 3 days ago

Current pager*:
, previous, 1 , 3, next,
first, previous, 1, 2, 3, 4, , 6, 7, 8, 9, ..., next, last

Purposed pager:
previous, 1, , 3, next
first, previous, 1, 2, 3, 4, , 6, 7, 8, 9, ..., next, last

The key difference is the removal of the "first" and "last" links when the number of pages is less than the quantity limit. The quantity limit truncates the number of pages shown in the list and adds an ellipsis (see examples above).

"First" and "last" buttons are redundant, confusing, and ugly when a pager only contains a small number of pages. In the first scenario above, the user is presented with 7 different links. However, "first" and "1" as well as "last" and "3" go to the same location. This means that the user must navigate 7 different options when only three different pages are being linked to. It is very clear that if the users clicks "1" it goes to the first page and if the user clicks the last number it goes to the last page. The more options a user is presented with, the more time it takes them to decipher and select the appropriate option. In the first example above, the seven links should be condensed to five links (see example 3).

"First" and "last" buttons should remain on pagers larger than the $quantity (default: 9) since the first and/or last page number may not be displayed depending on what page the user is on. In this case the additional buttons serve a purpose.

Some might want to take this a step further. If the "first" and "last" links are removed from small pages, why not remove the "next" and "previous" links? This would not be a good choice. Although these links go to the same location, users do not always know what page they are on, especially if the page being displayed is not well highlighted in the pager. Next and previous links allow users to easily move on to the next or previous page without knowing what page they are on.

Implementation of this change would be very simple. The number of pages ($pager_max) and the maximum number of page numbers to display ($quantity) already exist. I am not fluent enough with CVS to write a patch, however, you can see a purposed code change below:

Current (theme_pager()):

...
    if ($li_first) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => $li_first,
      );
    }
...
    if ($li_last) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => $li_last,
      );
    }
...



Purposed (theme_pager()):

...
    if ($li_first&&$pager_max>$quantity) {
      $items[] = array(
        'class' => 'pager-first',
        'data' => $li_first,
      );
    }
...
    if ($li_last&&$pager_max>$quantity) {
      $items[] = array(
        'class' => 'pager-last',
        'data' => $li_last,
      );
    }
...

*Pager separation has been modified from spaces to commas for clarity.

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

views.module

Created by

πŸ‡ΊπŸ‡ΈUnited States theabacus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024