function template_preprocess_views_view_row_search

Same name in other branches
  1. 7.x-3.x modules/search.views.inc \template_preprocess_views_view_row_search()

Template helper for theme_views_view_row_search

Related topics

File

modules/search.views.inc, line 183

Code

function template_preprocess_views_view_row_search(&$vars) {
    $vars['node'] = '';
    // make sure var is defined.
    $nid = $vars['row']->nid;
    if (!is_numeric($nid)) {
        return;
    }
    $node = node_load($nid);
    if (empty($node)) {
        return;
    }
    // Build the node body.
    $node = node_build_content($node, FALSE, FALSE);
    $node->body = drupal_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');
    $vars['url'] = url('node/' . $nid);
    $vars['title'] = check_plain($node->title);
    $info = array();
    $info['type'] = node_get_types('name', $node);
    $info['user'] = theme('username', $node);
    $info['date'] = format_date($node->changed, 'small');
    $extra = node_invoke_nodeapi($node, 'search result');
    if (isset($extra) && is_array($extra)) {
        $info = array_merge($info, $extra);
    }
    $vars['info_split'] = $info;
    $vars['info'] = implode(' - ', $info);
    $vars['node'] = $node;
    // @todo: get score from ???
    
    //$vars['score'] = $item->score;
    $vars['snippet'] = search_excerpt($vars['view']->value, $node->body);
}