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.
1 Answer
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; } }
current_page_num * num_per_page
is the upper limit of the range in the query, so 14 * 10 = 140:SELECT * FROM foo LIMIT 10, 140
. Similarly 30 * 10 = 300:SELECT * FROM foo LIMIT 10, 300
, which for a table with <= 140 records will produce the same resultset. What you're looking at is by design, I'm not sure there's an easy way to get around it