1. 6.x modules/search/search-results.tpl.php
  2. 7.x modules/search/search-results.tpl.php

Default theme implementation for displaying search results.

This template collects each invocation of theme_search_result(). This and the child template are dependent to one another sharing the markup for definition lists.

Note that modules may implement their own search type and theme function completely bypassing this template.

Available variables:

  • $search_results: All results as it is rendered through search-result.tpl.php
  • $module: The machine-readable name of the module (tab) being searched, such as "node" or "user".

See also

template_preprocess_search_results()

File

modules/search/search-results.tpl.php
View source
<?php

/**
 * @file
 * Default theme implementation for displaying search results.
 *
 * This template collects each invocation of theme_search_result(). This and
 * the child template are dependent to one another sharing the markup for
 * definition lists.
 *
 * Note that modules may implement their own search type and theme function
 * completely bypassing this template.
 *
 * Available variables:
 * - $search_results: All results as it is rendered through
 *   search-result.tpl.php
 * - $module: The machine-readable name of the module (tab) being searched, such
 *   as "node" or "user".
 *
 *
 * @see template_preprocess_search_results()
 *
 * @ingroup themeable
 */
if ($search_results) {
  ?>
  <h2><?php

  print t('Search results');
  ?></h2>
  <ol class="search-results <?php

  print $module;
  ?>-results">
    <?php

  print $search_results;
  ?>
  </ol>
  <?php

  print $pager;
}
else {
  ?>
  <h2><?php

  print t('Your search yielded no results');
  ?></h2>
  <?php

  print search_help('search#noresults', drupal_help_arg());
}

Related topics

Comments

ibit’s picture

1) Override templlate_preprocess_search_result(&$variables) as YOURTHEME_templlate_preprocess_search_result(&$variables)
2) Add new variable:

// Add image to product search result 
 if ($result['node']->type == "product") {
     $node = node_load($result['node']->nid);
     $prod_image = field_view_field('node', $node, 'uc_product_image', $display = array());
     $variables['image'] = $prod_image;
 }

3) Copy search-result.tpl.php to your templates
4) Render image :

<?php if($image):?>
        <?php print render($image);?>
<?php endif; ?>

5) Profit!