2

I am using apachesolr on my drupal 6 website for search. Now I wanted to use filter results by content type on search page. At first I was using a panel page as search page. Here I tried to use the apachesolr filter by content type block. But this didnt work. I tried all other facets available with apachesolr module and all others worked fine. Now I thought maybe filter by content type doesnt work with panels quiet well so i removed the panel page and used the apachesolr default search psge. Still it doesnt work for me.

Can someone tell me some method for grouping my search results by content type.

  • "Does not work" is not a very good description. What are the expected results? What are the actual results? Which version of apachesolr.module are you using? What do your settings look like in admin/settings/apachesolr ? – kekkis Aug 23 '12 at 8:13
0

I have used same thing in Drupal 7 . Please check if this can help

Function custom_preprocess_search_results(&$variables) {
  $variables['search_results'] = '';
  $resultTypes = array();

  // Divide results
  foreach ($variables['results'] as $result) {
    $resultTypes[$result['bundle']][] = $result;   
  }

  // Create fieldsets
  foreach ($resultTypes as $resultType => $resultTypeResults) {
    $value = '';


    foreach ($resultTypeResults as $result) {
      $value .= theme('search_result', array('result' => $result, 'module' => $variables['module']));



  $variables['search_results'] .= theme('fieldset', array('element' => array('#title' => $resultType, '#children' => $value));
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.