User login

Theme Drupal search results

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; }

Resolution

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;
}
?>

Searched words: 
themeing search results view

Comments

Hi I am using this code in

Hi

I am using this code in my template.php file. But it not showing any new look of page. I am using Drupal 6.14.

Any other things required to do? Please help.

Thanks
Hiral

This code is all Drupal 5

The main theme_ functions for search results display were removed in Drupal 6.

Instead, copy search-result.tpl.php or search-results.tpl.php from modules/search to your theme directory and modify them as needed there.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.