You are here

function apachesolr_attachments_apachesolr_process_results in Apache Solr Attachments 5

Same name and namespace in other branches
  1. 6 apachesolr_attachments.module \apachesolr_attachments_apachesolr_process_results()
  2. 6.2 apachesolr_attachments.module \apachesolr_attachments_apachesolr_process_results()

Implementation of hook_apachesolr_process_results().

When using the core Apache Solr module, everythign is treated as a node and as such the link and type wont be configured correctly if it is a file attachement, so override those values here if needed.

File

./apachesolr_attachments.module, line 187
Provides a file attachment search implementation for use with the Apache Solr module

Code

function apachesolr_attachments_apachesolr_process_results($results) {
  if (is_array($results)) {
    foreach ($results as &$item) {
      if (isset($item['node']->bsfield_isfile) && $item['node']->bsfield_isfile === TRUE) {
        $nid = $item['node']->nid;
        $node_title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $nid));
        $item['snippet'] = l($node_title, "node/{$nid}") . ': ' . $item['snippet'];
      }
    }
  }
}