Currently Search results in links with details,
It probably will be more appealing if results appear as images , link and title for more usability.

Thank you
Vasundhar

Comments

vasundhar’s picture

Assigned: vasundhar » Unassigned
thinkdrupal’s picture

Version: » 7.x-1.x-dev
Assigned: Unassigned » thinkdrupal
Status: Needs work » Needs review
StatusFileSize
new3.41 KB
new2.08 KB

Here are the changes for the images for Products to show in search

In template.php (under sigma theme), add this function.

?>function sigma_preprocess_search_result(&$variables) {
	// Add to result for displaying images for products.
	$n = node_load($variables['result']['node']->nid);
	$build = node_view($n, 'search_result');
    if (isset($build['product:field_image'][0]['#item']['uri']) && (!empty($build['product:field_image'][0]['#item']['uri']))){
	  $n->product_image = $build['product:field_image'][0]['#item']['uri'];
	  $variables['result']['product_image']= theme_image_style(array( 'path' => $n->product_image, 'style_name' => 'product-thumbnail', 'width'=>'100', 'height'=> '100'));
    }
}

Take a copy of search-result.tpl.php from core, and place in the template folder under sigma theme. ../sigma/templates

Make the following changes..

  <h3 class="title"<?php print $title_attributes; ?>>
    <a href="<?php print $url; ?>"><?php print $title; ?></a>
 <?php if (isset($result['product_image']) && (!empty($result['product_image']))): ?>
       <span class="search-image"><?php print $result['product_image']; ?></span>
    <?php endif; ?>
  </h3>

clear cache.
You may want to add some css based on how you want it to look.