Hello all,

I am just trying to implement a custom search in my site. Here i wish to search a particular node. Is there an easy way to do this. I was thinking if i could just add a small piece of code in the advanced search to restrict the search to a particular node.

Thanks in advance.

Regards,
Deepak.

Comments

tommo’s picture

You can override the results on a search page by using a template in your theme:

1. Create a template.php file in your theme directory if there's not already one there.
2. add the following

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

  foreach ($results as $entry) {
    if($entry['node']->type == "CHANGE_THIS_TO_TYPE_OF_NODE"){
      $output .= theme('search_item', $entry, $type);
    }
  }
  $output .= '</dl>';
  $output .= theme('pager', NULL, 10, 0);

  return $output;
}

3. change the part in the if statement: CHANGE_THIS_TO_TYPE_OF_NODE, to the node type you want to display (eg. 'page' or 'story' etc).

Hope this helps.

I have a problem that you might be able to help me with (or anyone else):

How can I set the number of results per page? (It displays 10, I want 9)