Categories: Creating and Editing :

Next Page Link on CSE Search Results

Showing 1-8 of 8 messages
Next Page Link on CSE Search Results stambox 12/13/09 4:45 AM
Hey Guys,

I was wondering if there is a way to display a "Next >>" link next to the CSE page numbers,
at the bottom of the search results.

for example:

1 2 3 4 5 6 7 8 Next >>

When clicking "Next >>" depending on your current page number it will go to next one.

Thanks.
Re: Next Page Link on CSE Search Results AdamCoppin 7/19/10 9:30 AM
Seconded - is this possible with CSE?
Re: Next Page Link on CSE Search Results omr 7/19/10 7:45 PM

Find a line like this in your search box code:

   customSearchControl.draw('cse');

Above that line, add the experimental code given here:

   http://codepad.org/La9h46CV

That should give you a "Next >>" page link.

-- omr

Re: Next Page Link on CSE Search Results omr 7/27/10 8:01 PM
Here is an update to fix a bug in my previously posted code.  The previous version displayed the "Next" link even on the last page of results.  This corrected version does not display the "Next" link on the last page.

http://codepad.org/Rs5jK7Jw

-- omr

Re: Next Page Link on CSE Search Results AdamCoppin 8/24/10 10:13 AM
Code works great!  Do you have any updates for including the previous link too, or should I take a look at further customizing your code?

Thanks!
Re: Next Page Link on CSE Search Results AdamCoppin 8/24/10 11:11 AM
Actually - figured it out myself from your code!

customSearchControl.setSearchCompleteCallback(
    this,
    function(control, searcher) {
      currentSearcher = searcher;
      var divs = document.getElementsByTagName('div');
      var div, div2, div3;
      for (var i=0;  div = divs[i];  i++) {
        if (/^gsc-cursor$/.test(div.className)) {
          var divs2 = div.getElementsByTagName('div');
          for (var j=0;  div2 = divs2[j];  j++) {
            if (/next-page-link/.test(div2.className)) {
              break;
            }
          }
          for (var j=0;  div3 = divs2[j];  j++) {
            if (/prev-page-link/.test(div3.className)) {
              break;
            }
          }
          if (!div2 &&
              searcher.cursor &&
              searcher.cursor.currentPageIndex <
                currentSearcher.cursor.pages.length - 1) {
            div2 = document.createElement('div');
            div2.className = 'gsc-cursor-page next-page-link';
            div2.onclick =
              function() {
                if (searcher.cursor &&
                    searcher.cursor.currentPageIndex <
                      currentSearcher.cursor.pages.length - 1) {
                  searcher.gotoPage.call(
                    searcher, searcher.cursor.currentPageIndex + 1);
                }
              };
            div2.innerHTML = 'Next >>';
            div.appendChild(div2);
          }
          if (!div3 &&
              searcher.cursor &&
              searcher.cursor.currentPageIndex >
                0) {
            div3 = document.createElement('div');
            div3.className = 'gsc-cursor-page prev-page-link';
            div3.onclick =
              function() {
                if (searcher.cursor &&
                    searcher.cursor.currentPageIndex >
                      0) {
                  searcher.gotoPage.call(
                    searcher, searcher.cursor.currentPageIndex - 1);
                }
              };
            div3.innerHTML = '<< Prev';
            //div.appendChild(div3,div);
            div.insertBefore(div3,div.childNodes[0]);
          }
        }
      }
    });

Thanks!
Re: Next Page Link on CSE Search Results ARFF 8/28/11 3:21 PM
I can get the "Prev" and "Next" links to display but when these links are selected, the page loads in place and doesn't scroll to the top.  Is there a way to have the page scroll to the top?
Re: Next Page Link on CSE Search Results bucketofsquid 8/30/11 8:48 AM
Too bad that Google doesn't just build this into the CSE/GSS.  Most people consider this standard functionality and the lack appears more as a flaw than anything.