Reputation: 871
Below is the code which i use for preprocessing the apache solr search results,
function apachesolr_search_apachesolr_process_results(&$results, DrupalSolrQueryInterface $query) {
$rows = array();
foreach ($results as $key => $fields) {
$rows [] = array(
'title' => t($fields['fields']['title']),
'Category' => $fields['fields']['category'],
'Dper' => $fields['fields']['crtor'],
'pvalue' => $fields['fields']['pvalue'],
'rvalue' => $fields['fields']['rvalue'],
'avalue' => $fields['fields']['avalue'],
);
}
$header = array(
array('data' => 'title', 'field' => 'title', 'sort' => 'ASC'),
array('data' => 'category', 'field' => 'category', 'sort' => 'ASC'),
array('data' => 'creator', 'field' => 'creator', 'sort' => 'ASC'),
array('data' => 'pvalue', 'field' => 'pvalue'),
array('data' => 'rvalue', 'field' => 'rvalue'),
array('data' => 'avalue', 'field' => 'avalue'),
);
$results['processresults'] = theme('table', array('header' => $header, 'rows' => $rows));
$results['processresults'] .= theme('pager');
return $results;
}
When i print the $results['processresults'] in the same function and give exit the table has been generated. if i return the $results and the table is not getting displayed in my apache solr search results page.
Upvotes: 0
Views: 2812
Reputation: 2015
The $results variable that's passed into the process_results() hook would have to maintain a certain structure for it to be able to continue working with the remainder of the hooks and templates that may be called on it.
So what I'd do if you want to customize your search results is look at the search-results.tpl.php and search-result.tpl.php template files (note the singular in the second one).
You can find copies of those in the core search module, and I'd just copy and paste those entire files (no need to even rename them) and put them in your custom theme's /templates/ folder. After clearing your cache, they should get picked up since they will have precedence now.
The search-results.tpl.php file controls how the entire search results page looks, while the search-result.tpl.php file controls who an individual search result is displayed (which fields, in which order, etc). Now that you have copies in your own custom theme, modify them any way you want!
Hopefully this is enough to get you started!!
Upvotes: 3