vanillaforums/Garden — Issue #1313: 'More Results' link seen only once when using MorePager
Author: Csabbencs
Created: 2012-03-06 14:45:21+00:00
State: open

I've just started to use "MorePager" and I noticed that despite the number of items in a certain result list the "More Results" link can be clicked only once, so after the view is refreshed it is gone, even if you have more results to show. To be more clear: let's say you have 43 items. First, what you see in the list is:
item 1
item 2
...
item 20
more results (link)
You click the link, what you see then is:
item 21
item 22
...
item 40
no more results (link)
You are not able to see item 41-43!

Check i.e vanillasearch for a frequently used word. http://vanillaforums.org/search

The bug is at method Index in SearchController in this logic:
'''	if($ResultSet)
$NumResults = count($ResultSet);
else
$NumResults = 0;
if ($NumResults == $Offset + $Limit)
$NumResults++;'''
$NumResults always equals to $Limit - except for the last page - that is a constant number of rows from database while $Offset is growing by pushing 'More Results' on and on, therefore, the condition 'if' is true only on first page.

A possible solution - assuming that $Limit is constant like it is in most of the cases - is checking if the current last record (Offset + Limit) is divisible by the number of results from database. If yes, then more link should be put on the screen.
'''	if($ResultSet)
$NumResults = count($ResultSet);;
else
$NumResults = 0;
if (($Offset + $Limit) % $NumResults == 0)
$NumResults = ($Offset + $Limit) + 1;'''

Please fix.