How do I add variables to a module's hook's existing render array and have them available as template variables? As an example, the hook_search_execute function returns the following array:

$results[] = array(
      'link' =&gt; url('node/' . $item-&gt;sid, array('absolute' =&gt; TRUE)),
      'type' =&gt; check_plain(node_type_get_name($node)),
      'title' =&gt; $node-&gt;title,
      'user' =&gt; theme('username', array('account' =&gt; $node)),
      'date' =&gt; $node-&gt;changed,
      'node' =&gt; $node,
      'extra' =&gt; $extra,
      'score' =&gt; $item-&gt;calculated_score,
      'snippet' =&gt; search_excerpt($keys, $node-&gt;body),
    );


'link' and 'title' are required and the others are optional. However, what if I wanted to add my element to the array like 'photo' and then have that available in the $search-result.tpl.php file?

Whe I add that element to the search results array, I indeed see it when I do a dump of $variables in _preprocess_search_result(). If it's available there, then how to I make it available as &lt;?php print $photo; ?&gt; in search-result.tpl.php?
According to template_preprocess_search_result you have the $result variable available, so if you've already injected your custom field into the result you can just use

print $result['photo'];


In the template file.

Or if you're absolutely set on just having a $photo var, you need to add it to the variables for the template:

function MYMODULE_preprocess_search_result(&amp;$vars) {
  $vars['photo'] = $vars['result']['photo'];
}