0
function mythemename_pager_next($text, $limit, $element = 0, $interval = 1, $parameters = array()) {
  global $pager_page_array, $pager_total;
  $output = '';

  // If we are anywhere but the last page
  if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {
    $page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);
    // If the next page is the last page, mark the link as such.
    if ($page_new[$element] == ($pager_total[$element] - 1)) {
      $output = theme('pager_last', $text, $limit, $element, $parameters);
    // The next page is not the last page.
    } else {
      $output = theme('pager_link', $text, $page_new, $element, $parameters);
      //$output = '<li class="custom-pager-next"><a class="active" href="javascript: void(0)"><img width="10" height="19" title="" alt="Previous" src="/' . path_to_theme() . '/img/pager-previous.png"></a></li>';
    }
  }

  return $output;

}

How to make NEXT PAGE link visible on last page? For example we have 3 pages and i am on the 3rd page and i should see NEXT page link. Please assist to me with function above, thanks!

1
  • What is the purpose of showing the next page link when the users are seeing the last page? What would you expect the link does, taking the users to the first page, or doing nothing?
    – apaderno
    Aug 11, 2019 at 10:50

1 Answer 1

1

The line

if ($page_new[$element] == ($pager_total[$element] - 1)) {

Will never fire because of the earlier line:

if ($pager_page_array[$element] < ($pager_total[$element] - 1)) {

So if the current page is equal to (or higher) then the last page it will skip the whole code.

Try removing that line (and the corresponding closing bracket }). I hovever don't know if it will keep working then because the following function seems to be assuming it can never load a pager higher then the current page. So prepare for some unexpected behavior.

$page_new = pager_load_array($pager_page_array[$element] + $interval, $element, $pager_page_array);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.