Drupal Views pager shows last page when higher pager value is entered manually instead of page not found I have a view with pager. The views pager is not AJAX and the pager id comes is the URL as
http://d7.local?page=3
There are total of 15 pages in the view.
So the last page is http://d7.local?page=14
Now if I manually enter a pager number which is higher that 14 say 30 it redirects to the last page
Need to redirect the user to a 404 page under this situation.
Found a way out!!..
I used theme_pager and global variable $pager_total

Here is the code


/**
 * Implements theme_pager
 */
function theme_pager($variables) {
  global $pager_total;
  if ($_GET['page'] > $pager_total[0]) {
    drupal_not_found();
    exit;
  }
}