How to turn on search results pagination?

Permalink
I see some stuff in the view template and the controller... What do I need to do to activate it?

BigBobbyD
View Replies: View Best Answer
BigBobbyD replied on at Permalink Reply
BigBobbyD
Bump -- I've spent hours poking around and trying different things, searching the forum, etc.

I suppose I could try to adapt the pagination script that was posted for the page list block before that functionality was built-in, but that just seems silly as there's clearly some code in the search block intended for pagination.

But I'm afraid my php skills aren't up to snuff to figure out what's going on what's up with this bit from the controller:
function do_search() {
      $q = $_REQUEST['query'];
      Loader::library('database_indexed_search');
      $ipl = new IndexedPageList();
      $ipl->filterByKeywords($q);
      if( is_array($_REQUEST['search_paths']) ){ 
         foreach($_REQUEST['search_paths'] as $path) {
            //if(!strlen($path)) continue;
            $ipl->addSearchPath($path);
         }
      }
      $res = $ipl->getPage(); 
      foreach($res as $r) { 
         $results[] = new IndexedSearchResult($r['cID'], $r['cName'], $r['cDescription'], $r['score'], $r['cPath'], $r['content']);
      }



Or this bit from the view:
if($paginator && strlen($paginator->getPages())>0){ ?>   
      <div class="pagination">   
          <span class="pageLeft"><?php echo $paginator->getPrevious()?></span>
          <span class="pageRight"><?php echo $paginator->getNext()?></span>
          <?php echo $paginator->getPages()?>
      </div>


I've scoured the helpers, models, libraries, api and forums for mention of $paginator or a getPages() function, but nothing... I'm clearly missing something simple, but...

Anyone? How can I hand this code the necessary to generate the pagination controls?

Thank you.
BigBobbyD replied on at Permalink Best Answer Reply
BigBobbyD
Ok...

starting at line 134 of search block's controller:

if( is_array($_REQUEST['search_paths']) ){ 
         foreach($_REQUEST['search_paths'] as $path) {
            //if(!strlen($path)) continue;
            $ipl->addSearchPath($path);
//set items per page for pagination
            $ipl->setItemsPerPage(4);
         }
      }


Just in case someone else gets stuck with this!
LucasAnderson replied on at Permalink Reply
LucasAnderson
I think it's on by default, however, I could be incorrect.
BigBobbyD replied on at Permalink Reply
BigBobbyD
If it's on by default, then perhaps all i need to do is edit the number of results displayed, but I can't find this variable either... Can't override helpers/pagination.php, which seems like it's playing some role here.
BigBobbyD replied on at Permalink Reply
BigBobbyD
The goofy design I've been given only has space for about five results...
msglueck replied on at Permalink Reply
msglueck
concrete/config/base.php:
# Default search size
define('SEARCH_CHUNK_SIZE','20'); /* number of entries retrieved per page */
wildws replied on at Permalink Reply
I have the same issue - did you manage to resolve it in the end?
BigBobbyD replied on at Permalink Reply
BigBobbyD
My answer I marked as the solution worked, but that was many c5 versions ago.

I would try setting the global SEARCH_CHUNK_SIZE as suggested by msglueck first.
wildws replied on at Permalink Reply
Yeah I tried that but it had no effect :(
BigBobbyD replied on at Permalink Reply
BigBobbyD
Have you tried the solution I marked as the answer?

It's pretty old, but you should look for the lines indicated.

The key for me was:
$ipl->setItemsPerPage(4);