1 search.views.inc template_preprocess_views_view_row_search(&$variables)

Template helper for theme_views_view_row_search

File

core/modules/search/views/search.views.inc, line 159
Provide views data and handlers for search.module.

Code

function template_preprocess_views_view_row_search(&$variables) {
  $variables['node'] = ''; // make sure var is defined.
  $nid = $variables['row']->nid;
  if (!is_numeric($nid)) {
    return;
  }

  // @todo: Once the search row is fixed this node_load should be replace by a node_load_multiple
  $node = node_load($nid);

  if (empty($node)) {
    return;
  }

  // Build the node body.
  $node = node_build_content($node, FALSE, FALSE);
  $node->body = backdrop_render($node->content);

  // Fetch comments for snippet
  $node->body .= module_invoke('comment', 'nodeapi', $node, 'update index');

  // Fetch terms for snippet
  $node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index');

  $variables['url'] = url('node/' . $nid);
  $variables['title'] = check_plain($node->title);

  $info = array();
  $info['type'] = node_type_get_name($node);
  $info['user'] = theme('username', array('account' => $node));
  $info['date'] = format_date($node->changed, 'short');
  $extra = module_invoke_all('node_search_result', $node);
  if (isset($extra) && is_array($extra)) {
    $info = array_merge($info, $extra);
  }
  $variables['info_split'] = $info;
  $variables['info'] = implode(' - ', $info);

  $variables['node'] = $node;
  // @todo: get score from ???
  //$variables['score'] = $item->score;
  $variables['snippet'] = search_excerpt($variables['view']->value, $node->body);
}