Tags:
create new tag
view all tags
I've often though it'd be useful to have a start= modifier to a formated search just like the count= modifier. That way you can control how may search results are displayed in a topic, but also provide a 'next' link, much like most internet search engines.

for example you could have a formated search tag like:

%SEARCH{"%URLPARAM{\"query\"}%" sort="modified" start="%URLPARAM{\"start\"}%" count="%URLPARAM{\"count\"}%" format="---+++ $topic"}%

to search for 'twiki' your first link would be:

topicname?query=twiki&start=1&count=10

you could then use some method (JavaScript, SpreadSheetPlugin, custom plugin, or formatted search could automatically generate it if start= is detected) to calculate the 'next' link:

topicname?query=twiki&start=(start+count)&count=10

and the 'previous' link:

topicname?query=twiki&start=(start-count)&count=10 (anything < 1 would = 1 of course)

and so on and so on. I don't imagine it'd be too difficult to trim the results from grep to suit the above parameters.

How does that sound?

-- AndrewTetlaw - 11 Feb 2002

Sounds like a useful extension and should not be too difficult to implement. Any takers?

-- PeterThoeny - 13 Feb 2002

Hey I'm a real Perl newbie so please excuse the following. I think a start=x argument would be very easy to implement. apart from the change to take $start as an argument (which would be trivial) I think all we'd need to do is change a few lines in: sub searchWeb in the TWiki::Search module.

It appears all we have to change is this:

    # then shorten list and build the hashes for date and author
    my $idx = $theLimit + 10;  # slack on limit
    @topicList = ();
    foreach( @tmpList ) {
        push( @topicList, $_ );
        $idx -= 1;
        last if $idx <= 0;
    }

to this:

    # then shorten list and build the hashes for date and author
    my $idx = $theLimit + 10;  # slack on limit
    $start = 0 if ( ! $start );
    @topicList = ();
    for( my $i = $start; $i < $idx; $i++) {
        push( @topicList, $tmpList[$i] );
    }

what do the Perl programmers think?

-- AndrewTetlaw - 01 Mar 2002

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2002-03-01 - AndrewTetlaw
 
  • 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.