We wanted the search engine for our site to do paging in the google style, so I've made the following changes to our htsearch/Display.cc that sets up another config variable (results_page_span) that allows you to display a set number of pages before and after the current page.  You still have to come up with graphics, or just use the text links, but it's great for large search result sets
 
Adam Ness
 
 
diff -r1.105 Display.cc
698a699
>         int pageSpan = config->Value("results_page_span", 10);
701,706c702,724
<           if (i == pageNumber)
<           {
<               p = npnt[i - 1];
<               if (!p)
<                   p = form("%d", i);
<               *str << p;
---
>             if ( i > ( pageNumber - pageSpan ) &&
>                  i < ( pageNumber + pageSpan ) ) {
>               if (i == pageNumber)
>               {
>                   p = npnt[i - 1];
>                   if (!p)
>                       p = form("%d", i);
>                   *str << p;
>               }
>               else
>               {
>                   p = pnt[i - 1];
>                   if (!p)
>                       p = form("%d", i);
>                   *str << "<a href="">>                   tmp = 0;
>                   createURL(tmp, i);
>                   *str << tmp << "\">" << p << "</a>";
>               }
>               if (i != nPages && sep.Count() > 0)
>                   *str << sep[(i-1)%sep.Count()];
>               else if (i != nPages && sep.Count() <= 0)
>                 *str << " ";
708,722c726
<           else
<           {
<               p = pnt[i - 1];
<               if (!p)
<                   p = form("%d", i);
<               *str << "<a href=""><               tmp = 0;
<               createURL(tmp, i);
<               *str << tmp << "\">" << p << "</a>";
<           }
<           if (i != nPages && sep.Count() > 0)
<               *str << sep[(i-1)%sep.Count()];
<           else if (i != nPages && sep.Count() <= 0)
<             *str << " ";
<       }
---
>         }

Reply via email to