The active page number is not showing on the last page(Views Full pager)

Created on 11 November 2022, about 2 years ago
Updated 2 June 2023, over 1 year ago

Problem/Motivation

There is a problem with the Views full pager, the active page number is not showing on the last page when the quantity value is 1.

Steps to reproduce

  • Create a view with full pager
  • In the pager option the "Number of pager links visible" should be 1
  • Go to the view page and go to the last page, the active page is not displaying in the pager
  • Change the pager option the "Number of pager links visible" to other values then the active page is displaying in the pager

Proposed resolution

This is because the following code on the template_preprocess_pager is not executing on the last page

  if ($i != $pager_max) {
    // Add an ellipsis if there are further previous pages.
    if ($i > 1) {
      $variables['ellipses']['previous'] = TRUE;
    }
    // Now generate the actual pager piece.
    for (; $i <= $pager_last && $i <= $pager_max; $i++) {
      $options = [
        'query' => $pager_manager->getUpdatedParameters($parameters, $element, $i - 1),
      ];
      $items['pages'][$i]['href'] = Url::fromRoute($route_name, $route_parameters, $options)->toString();
      $items['pages'][$i]['attributes'] = new Attribute();
      if ($i == $pager_current) {
        $variables['current'] = $i;
      }
    }
    // Add an ellipsis if there are further next pages.
    if ($i < $pager_max + 1) {
      $variables['ellipses']['next'] = TRUE;
    }
  }

The logic behind the check if ($i != $pager_max) { is not documented.
It does not really add up because in the nested for loop $i is allowed to be equal with $pager_max
for (; $i <= $pager_last && $i <= $pager_max; $i++) {

So remove if ($i != $pager_max) { condition from here.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Fixed

Version

10.1

Component
Theme 

Last updated 3 minutes ago

Created by

🇮🇳India ranjith_kumar_k_u Kerala

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