I want to configure the search module to paginate the search results so that it only shows 10 results per page. How can this be done?

Thanks,

Comments

vm’s picture

There is no reason to post multiple threads asking the same question. If you don't receive an answer in 12 - 24 hours, bump the original post.

I've removed the other threads.

From what I can see, the search.module does limit to 10 results per page.

what version of Drupal is in use?

mediumgrade’s picture

Version 5. Do I have to change the module directly?

How does one "bump" the original post?

vm’s picture

version 5 point what?

again, you state you want the search to show only 10 results and then be paginated, From what I can see on drupal.org it looks to me to already show 10 results with pagination.

how many results is your site showing?

I am not saying to hack the search.module, I am trying to clarify your question and insure we aren't chasing our tail here.

mediumgrade’s picture

My Apologies. Drupal 5.5.

If I wanted to change the number of results shown before pagination (say, 5 results, then paginate), where would I go?

vm’s picture

function theme_search_page($results, $type) {
  $output = '<dl class="search-results">';

  foreach ($results as $entry) {
    $output .= theme('search_item', $entry, $type);
  }
  $output .= '</dl>';
  $output .= theme('pager', NULL, 10, 0);

  return $output;
}

I believe the above function is what handles this in the search.module

That being said, I believe you can add this to your template.php and change the function name to YOURTHEME_search_page as per http://drupal.org/node/55126

Then you can change the integer 10 to 5.

That being said, I've not tested this, so do so on a test site.

mediumgrade’s picture

Actually, that wasn't it.

The line of code needing to be edited is in the search.module file on line 871 (in search module version 1.209.2.5)

$result = pager_query("SELECT * FROM temp_search_results", 10, 0, $count_query);

I simply changed the 10 to the desired number. The theme_pager function simply outputs some HTML to make the paging links at the bottom of the search results.

Now, while this works, I don't like having to edit the search module to do it. Is there a way for me to override the query? Is this something I should suggest for a future version of this module?

vm’s picture

you may be able to override with hook_form_alter, I've not tested it.

as far as features for a future version, if a patch was created that added this to the admin area under search settings and allowed variables to be set, I'd be all for it.

cbz47d’s picture

How to override the pagination number in drupal-6.13

Tchinkatchuk’s picture

No one knows ?
I am lookin for changes in pagination results number and pagination templating in drupal 6.x