2012-03-08, 12:47 PM
I'm currently using the following code to check if we're on the last page of a thread.
It works fine (except when you're in a URL without the page parameter, such as the lastpost or newpost features - any ideas on that?), but I think it's too much overhead to run a query for a simple thing like this. Is there an easier way to do it?
I'm aware of $mybb->input['page'] == "last" but it only works if we're actually on showthread.php?tid=123&page=last. If I try to go to the last page normally (e.g. showthread.php?tid=123&page=5) it doesn't work.
Thanks.
$thread = get_thread($mybb->input['tid']);
$perpage = $mybb->settings['postsperpage'];
$postcount = intval($thread['replies'])+1;
$pages = $postcount / $perpage;
$pages = ceil($pages);
if($mybb->input['page'] == $pages)
{
// Example
}
It works fine (except when you're in a URL without the page parameter, such as the lastpost or newpost features - any ideas on that?), but I think it's too much overhead to run a query for a simple thing like this. Is there an easier way to do it?
I'm aware of $mybb->input['page'] == "last" but it only works if we're actually on showthread.php?tid=123&page=last. If I try to go to the last page normally (e.g. showthread.php?tid=123&page=5) it doesn't work.
Thanks.