Search Result Customization
johnross.c - August 16, 2007 - 03:52
Hello!
I am baffled on how to customize the search result of Drupal... How can I let the search result view only the title and details of the page without showing the author or the date and number of comments after it...
Thank you very much...

Solution
hi,
You can add this code to your theme's Template.php file. Just replace the THEME-NAME with your own theme name.
<?phpfunction THEME-NAME_search_item($item, $type) {
$output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';
$info = array();
$output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';
return $output;
}
?>
Actually this theme function overrides the search result function in search.module.
here is the original code, you can leave some items like date or ...
<?phpfunction THEME-NAME_search_item($item, $type) {
$output = ' <dt class="title"><a href="'. check_url($item['link']) .'">'. check_plain($item['title']) .'</a></dt>';
$info = array();
if ($item['type']) {
$info[] = check_plain($item['type']);
}
if ($item['user']) {
$info[] = $item['user'];
}
if ($item['date']) {
$info[] = format_date($item['date'], 'small');
}
if (is_array($item['extra'])) {
$info = array_merge($info, $item['extra']);
}
$output .= ' <dd>'. ($item['snippet'] ? '<p>'. $item['snippet'] .'</p>' : '') .'<p class="search-info">'. implode(' - ', $info) .'</p></dd>';
return $output;
}
?>
N.Mehrabany
Baruzh web design & programming
Thank you..
I'll try these codes this insatan...