drupal - Glossary type facet from Node Index -


problem/motivation

i using search api solr search api integration. have 1 node index showing content type listing , 1 faceted block attached (category). idea create faceted block filter starting letter of listing title.

i think have tried (then again maybe not...) except creating new indexed field, trimming title first letter , using filter titles.

this solved problems. adding field index , can create facet out of it.

function wtc_glossary_search_api_alter_callback_info() {   $callbacks['wtc_glossary_alter_add_first_letter_title'] = array(     'name' => t('first letter of listing title'),     'description' => t("this module provides first letter of title glossary view."),     'class' => 'wtcalteraddfirstletter',   );    return $callbacks; }  /**  * search api data alteration callback adds first letter of title  glossary mode  */ class wtcalteraddfirstletter extends searchapiabstractaltercallback {    public function alteritems(array &$items) {     foreach ($items $id => &$item) {       if (!isset($item->field_you_need)) {         $item->search_api_title_first_letter = null;         continue;       }       $item->search_api_title_first_letter = substr($item->field_you_need,0,1);     }   }    public function propertyinfo() {     return array(       'search_api_title_first_letter' => array(         'label' => t('first letter of field_you_need'),         'description' => t('for listings in glossary mode.'),         'type' => 'text',       ),     );   }  } 

Comments