MyBB Community Forums

Full Version: Infinite Scroll
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
https://github.com/WildcardSearch/ScrollOn

I'm working on a plugin that will enable AJAX load in the thread view. So far, so good in terms of getting the fundamentals coded, but I'd like a little advice on certain aspects of how the plugin should behave and would welcome your input.

Feel free to try the plugin out on a test board, but I wouldn't recommend using it on a live forum just yet.

Current Behavior

There are two main ON/OFF controls that effect how the plugin works.

Auto Mode

In this mode when the user reaches the end of the page, the next page of threads are loaded via AJAX. Admin can specify how many posts to load at one time or leave that setting blank to default to the user's posts-per-page setting (whcih in turn defaults to the MyBB def. ppp setting if it is unset).

When Auto is off (default), users are shown a link to load more posts.

Live Mode

When Live mode is on, when the user has scrolled to the end of the thread, admin can specify a refresh to check for new posts.

When live mode is off (default) there is no side-effects.



Most of my issues are in semantics. If anyone can find time to test this and give me some feedback on what works for you and what doesn't (both operationally and behaviorally) I would be appreciative.
Can I just comment on this,


	// and then grab its dateline
	$query = $db->simple_select('posts', 'dateline', "pid='{$pid}'", array("limit" => 1));
	if($db->num_rows($query) == 0)
	{
		// something went wrong
		return;
	}
	$dateline = (int) $db->fetch_field($query, 'dateline');

Why not

$dateline = (int) $db->fetch_field($db->simple_select('posts', 'dateline', "pid='{$pid}'", array("limit" => 1)), 'dateline');

if($dateline == 0)
		return;

As (int) or intval will convert it to 0 if null either way
I see where you are going with that, but that isn't my coding style. I prefer to write in a more manageable style.