Hello everyone

Im trying to output the values from a line of specific fields in my custom content type. I've copied the search-result.tpl.php to my template to modify it.

I have found several posts about how to do it in D6, but Im not having success with it in D7 (nor finding posts about it).

For example I have a field called field_venue (in my custom content type) and I really want to output the value of that field in my search-result.tpl.php.

I've tried to output the value with the following:

print render($result['field_venue']);

and (which works in my node view, e.g. node--mynode.tpl.php)

print render($content['field_venue']);

Neither of the above works in my search-result.tpl.php, unfortunately.

What am I missing?

Thanks, in advance.

Tue

Comments

iTjensen’s picture

Does anyone have any clue how to fix my issue? :)

Thanks.

discipolo’s picture

Did you figure this out?
The only way I have found to get images into search results in D7 is :

$node = node_load($result['node']->nid);
print '<img src=' . '/sites/default/files/images/'. $result['node']->field_cover_image[de][0][filename] . ' />'; 

but this doesn't seem to be the right way to do it. First of all because of node_load, and of course this image is not run through 'image_styles' ..

discipolo’s picture

  $path = image_style_url('thumbnail', $result['node']->field_cover_image['de'][0]['uri']);
  print theme('image', array(
  'path'  => $path,
  'alt'   => t('Home'),
  'title' => t('Home')))

lucky i found this: http://www.zites.net/en/drupal-7-theming-and-image-path