I'd like my search results to appear visually the same as my site nodes do.

To do this I need to add additional node specific data such as taxonomy etc etc.

Is there an existing variable for node id that I can use within search-result.tpl.php

i.e. node_load($search->nid) ?

I'm sure I must be missing something as it seems really basic to make the node variables available here.

Or any other way to load node data into this template?

Thanks!

Comments

unxposed’s picture

This really doesn't exist?

unxposed’s picture

$results['node']

I just used $node = $results['node'] and all my node.tpl.php template code worked in search-result.tpl.php

leenwebb’s picture

In case someone comes across this in the future -- I believe the correct variable is actually
$result['node'] (not plural 'results').

BigMike’s picture

In case someone comes across this in the future -- I believe the correct variable (for instance to print the node ID) is actually
$result[node]->nid

GinaF’s picture

I just found this to work:
$entity->nid;
edit - Sorry, to clarify, I am using Display Suite to edit the appearance of my search results (which is very good), and in it the $entity object is available.

harryma’s picture

In case someone comes across this in the future -- I believe the correct variable (for instance to print the node ID) is actually
$result[node]->nid

this worked!

Drupal 6.22

BigMike’s picture

Thank you for the confirmation harryma :-)

joseonate’s picture

This solution also works for Drupal 7.

To reiterate: In search-result.tpl.php, $result['node'] will contain the node object.