Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x01x02
TWiki plugins:  
Server OS: Windows XP
Web server: Apache 2.2.6
Perl version: 5.8.8
Client OS: Windows XP
Web Browser: IE 6
Categories: Search

-- TWikiGuest - 03 Jan 2008

Answer

ALERT! 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

Change status to:
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2008-01-05 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.