Theme Drupal search results

Key words and phrases: 
themeing search results view
Description & Info: 

theme_search_item($item, $type)

http://api.drupal.org/api/function/theme_search_item/5

http://drupal.org/node/175013 => Customize the search results page

A separate issue raised in IRC:

now to disable user searching.
[07:50am] ben-agaric: http://drupal.org/node/85137 - Remove tab from search page
Better general instructions for removing a tab: http://drupal.org/node/68792

original requester: for my needs, my code is much simpler than the more generic solution others have posted.
[08:21am] // we need to remove the 'search users' tab on the search page.
[08:21am] // since that would only leave the 'Content' tab, we can just
[08:21am] // NULL out all tabs for that page and be done with it.
[08:21am] if (arg(0) == 'search') { $vars['tabs'] = NULL; }

In template.php, do not paste in opening <?php tag if one has already been opened and the closing ?> tag should be dropped from the end of all Drupal module and theme files per coding standards:

<?php
function phptemplate_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 (
user_access('administer content')) {
    if (
$item['user']) {
     
$info[] = $item['user'];
    }
    if (
$item['date']) {
     
$info[] = format_date($item['date'], 'small');
    }
   
$info[] = l('edit', 'node/' . $item['node']->nid . '/edit');
  }
  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;
}
?>

Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.