logo

New Response

« Return to the main article

You are replying to:

  1. I took this code and ran with it, tinkering along the way. The result is:

    - If there are 15, then you'll see a group "11-15", not "11-20" - An "All" link appears so users have the option of getting all results. - Assuming no more than 250 documents, there are a maximum of 25 groups, so a list of 1 through 25 is hardcoded rather than doing sequential number generation. - The count is customizable through the URL. On our advanced search form is a combo box allowing the user to choose to get results by 10s, 25s, or 50s. This is sent in the "count" argument of the URL. - variable names have been changed to fit within my client's coding standards (integer variables prefixed with "i", etc)

    REM "NOTE: start param must be before count param in the original URL"; REM "We are limited to 250 docs by domino!!"; sOldCount := @Middle(Query_String; "&oldcount="; "&"); sCountNum := @Middle(Query_String; "&count="; "&"); iCountNum := @If(sOldCount != ""; @TextToNumber(sOldCount); sCountNum != ""; @TextToNumber(sCountNum); 10); iHitNum := @Min(TotalHits; 250); @If(iHitNum <= iCountNum; @Return(""); continue); sHitNum := @Text(iHitNum); sStartNum := @Middle(Query_String; "&start="; "&"); sNewCountNum := @Text(iCountNum);

    REM "get number of groups"; iGroups := @Integer((iHitNum - 1) / iCountNum) + 1; REM "It\'s assumed that iCountNum will never be less than 10, so max of 25 groups is hardcoded."; aDigits := 0: 1 : 2 : 3 : 4 : 5 : 6 : 7 : 8 : 9 : 10 : 11 : 12 : 13 : 14 : 15 : 16 : 17 : 18 : 19 : 20 : 21 : 22 : 23 : 24; aStarts := @Text(@Subset(aDigits; iGroups) * iCountNum + 1); aRanges := aStarts + " - " + @Text(@If( iGroups = 1; iHitNum; ((@Subset(aDigits; iGroups - 1) + 1) * iCountNum) : iHitNum));

    sGroups := "<a href=\"?" +@ReplaceSubstring(Query_String; ("&start=" + sStartNum) : ("&count=" + sCountNum); "") + "&count=" + sNewCountNum + "&start=" + aStarts + "\">" + aRanges + "</a>";

    sAll := "<a href=\"?" + @ReplaceSubstring( Query_String; ("&count=" + sCountNum) : ("&start=" + sStartNum); ("&count=" + sHitNum) : "") + @If(@Contains( Query_String; "&oldcount="); ""; "&oldcount=" + sNewCountNum) + "\">All</a>";

    @Text(""+ @Implode(sGroups : sAll;" | ")+ "")

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: