Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: PHP  |  size: 1.40 KB  |  hits: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /**
  4.  * @file
  5.  */
  6.  
  7. /**
  8.  *
  9.  * @param type $mappings
  10.  * @param type $entity_type
  11.  */
  12. function apachesolr_text_apachesolr_field_mappings_alter(&$mappings, $entity_type) {
  13.   // Enable indexing for text fields
  14.   $mappings['text'] = array(
  15.     'indexing_callback' => 'apachesolr_fields_default_indexing_callback',
  16.     'map callback' => '',
  17.     'index_type' => 'string',
  18.     'facets' => TRUE,
  19.     'facet missing allowed' => TRUE,
  20.     'dependency plugins' => array('bundle', 'role'),
  21.     'hierarchy callback' => FALSE,
  22.     'name_callback' => '',
  23.     'facet mincount allowed' => FALSE,
  24.     // Field API allows any field to be multi-valued.
  25.     // If we set this to false we are able to sort
  26.     //'multiple' => FALSE,
  27.   );
  28. }
  29.  
  30. /**
  31.  * Prepare the query by adding parameters, sorts, etc.
  32.  *
  33.  * This hook is invoked before the query is cached. The cached query is used
  34.  * after the search such as for building facet and sort blocks, so parameters
  35.  * added during this hook may be visible to end users.
  36.  *
  37.  * This is otherwise the same as HOOK_apachesolr_query_alter(), but runs before
  38.  * it.
  39.  *
  40.  * @param object $query
  41.  *  An object implementing DrupalSolrQueryInterface. No need for &.
  42.  */
  43. function apachesolr_text_apachesolr_query_prepare($query) {
  44.   // Add a sort on the node ID.
  45.   $query->setAvailableSort('its_field_year', array(
  46.     'title' => t('Year'),
  47.     'default' => 'asc',
  48.   ));
  49. }