1

I have a content type called "people". When a search is made and one of the search results is of "people" type, I want to display two fields of the "people" type; an image called "photo", and a text filed called "email".

Under "Manage Display" of the "people" content type, I selected custom display types and selected "Search Result" box. After saving, I selected the new "Search result" button and hid all other fields except "photo" and "email". I then customized the photo to have image style of "thumbnail".

I saved, cleared the cache, and reindexed the site. The search results are correct but no images are shown. I am very new to Drupal; all the help I could find is for Drupal 6 and by reading the comments people say that the solutions shown do not work for Drupal 7.

  • When you select a page with the full content type on it, does the photo show? (Is your link to the photo correct to display the field?) What theme are you using, or is it a custom theme? – Ashlar Nov 1 '11 at 0:38
  • yes, photo shows when viewing full page. Yes, image is linked to itself so clicking on image loads a new page with image at full size. I am using a custom sub-theme of zen. – joe Nov 1 '11 at 3:51
4

This is a core issue. See http://drupal.org/node/1166114.

Workaround is to add this to your theme's template.php. Also copy search-result.tpl.php from the core search module into your theme folder and clear cache.

function YOURTHEME_preprocess_search_result(&$variables) {
  $result = $variables['result'];
  if (isset($result['node'])) {
    $variables['snippet'] = $result['node']->rendered;
  }
}

The rendered node will pick up the Manage Display settings.

1

You have to isolate the issue first. Open up Firebug or your browser's developer tools and see if HTML is being output for the image. Maybe the path to the image is wrong in the search results for one reason or another. Also, ensure that you selected the proper formatter over at Manage Display (e.g. a formatter that works in another view mode).

Finally, check which template file is being used to output search results. Maybe this is getting in the way.

  • No, I am displaying the label above the image and that is there. The Email test is there. There is nothing (no code at all) for the image, so no image path to check. Yes, I am using the correct formatter for "Search result". – joe Nov 1 '11 at 3:59
  • I am using the default template files as given in the zen theme. Considering how mature the zen theme is I doubt if the default template files are getting in the way. – joe Nov 1 '11 at 4:03
  • To rule out the theme definitively - if you switch to the default theme (i.e., Bartik), does everything work? Double-check Manage Display after doing this to verify your configuration stays intact. – wizonesolutions Nov 1 '11 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.