Question
Hello guys, is it possible to paginate the search results? Assuming that I have more than 100 search results, it would be great if the results can be displayed in 5 pages with each page containing 20 results. Is it possible to do so with the
%SEARCH% operator?
Environment
--
TWikiGuest - 03 Jan 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
At this point, SEARCH does not support pagination. You
might be able to get pagination by conditionally suppressing search results in the
format="" parameter with
SpreadSheetPlugin calculations. Example:
%CALC{ $SET(offset, %URLPARAM{ "offset" default="1" }%) $SET(size, 10) $SET(i, 0) $SET(high, $INT($GET(offset)+$GET(size)))}%
%SEARCH{
"%URLPARAM{search}%"
nonoise="on"
format="$percntCALC{$SETM(i, +1)$IF($GET(i)<$GET(offset), <nop>, $IF($GET(i)>=$GET(high), <nop>, | $GET(i) | [[$topic]] | $wikiusername - $date |))}$percnt"
}%
%CALC{$IF($GET(i)<$GET(high), , [[%SCRIPTURLPATH{view}%/%WEB%/%TOPIC%?search=%URLPARAM{ "search" encode="url" }%;offset=$INT($GET(size)+%URLPARAM{ "offset" default="1" }%)][Next $GET(size)]] of) $GET(i) hits}%
The
size is hard coded; it could be supplied by
%URLPARAM{}%.
See working example at
PaginatedSearch.
--
PeterThoeny - 04 Jan 2008
Assume that there are 100 topics in a web.
Hence, if we run this search, does this mean that, even though only 20 is displayed to the user, all 100 topics are run through each time we click through to the next search result page?
--
TWikiGuest - 04 Jan 2008
Yes
--
RafaelAlvarez - 04 Jan 2008
On the server, yes. However, only the 20 visible table rows are rendered and returned to the browser. That is, efficient on the network and browser, not so efficient on the server if you have 10,000s of records.
--
PeterThoeny - 04 Jan 2008
See working example at
PaginatedSearch.
--
PeterThoeny - 05 Jan 2008