Check if we're on the last page
#11
Yes, I can use showthread_end. I gave it a go and now have the following code:

if($mybb->input['pid'])
{
	if(($result % $perpage) == 0)
	{
		$mybb->input['page'] = $result / $perpage;
	}
	else
	{
		$mybb->input['page'] = intval($result / $perpage) + 1;
	}
}

I then globalized $result. It works and the issue is fixed now, but is ok to do this? I mean, can I just globalize variables like that instead of defining them? For example, would it be ok to remove the following code and instead put those variables in the global scope? (I've tested it, both methods work)

$perpage = $mybb->settings['postsperpage'];
$postcount = intval($thread['replies'])+1;
$pages = $postcount / $perpage;
$pages = ceil($pages);

Thanks again for your help.
Reply
#12
Using globals is a whole 'nother topic for discussion, but it is fine to make $result global and use it where you need.

Would you mind PM'ing me the plugin code? I can better understand what you are trying to do and offer any optimization advice then.
Lost interest, sold my sites, will browse here once in a while. It's been fun.
Reply
#13
Of course, I'm doing it right now. Sorry I didn't provide much information initially, I didn't think it would get this complicated. Thanks by the way! Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)