You are here

function apachesolr_autocomplete_init in Apache Solr Autocomplete 7

Same name and namespace in other branches
  1. 6 apachesolr_autocomplete.module \apachesolr_autocomplete_init()
  2. 7.2 apachesolr_autocomplete.module \apachesolr_autocomplete_init()

Implementation of hook_init().

File

./apachesolr_autocomplete.module, line 14
Alters search forms to suggest terms using Apache Solr using AJAX. Thanks to: robertDouglass who contributed some of the code. sch4lly for contributing to D7 version

Code

function apachesolr_autocomplete_init() {
  drupal_add_css(drupal_get_path('module', 'apachesolr_autocomplete') . '/apachesolr_autocomplete.css');

  // If using custom JS widget, include its files and settings.
  if (apachesolr_autocomplete_variable_get_widget() == 'custom') {

    // Add custom autocomplete files
    drupal_add_js(drupal_get_path('module', 'apachesolr_autocomplete') . '/apachesolr_autocomplete.js');
    drupal_add_js(drupal_get_path('module', 'apachesolr_autocomplete') . '/jquery-autocomplete/jquery.autocomplete.js');
    drupal_add_css(drupal_get_path('module', 'apachesolr_autocomplete') . '/jquery-autocomplete/jquery.autocomplete.css');

    // Specify path to autocomplete handler.
    drupal_add_js(array(
      'apachesolr_autocomplete' => array(
        'path' => url('apachesolr_autocomplete'),
      ),
    ), 'setting');
  }

  // If using jQuery UI autocomplete, include its files and settings.
  if (apachesolr_autocomplete_variable_get_widget() == 'jqueryui') {
    drupal_add_library('system', 'ui.autocomplete');
    drupal_add_js(drupal_get_path('module', 'apachesolr_autocomplete') . '/apachesolr_autocomplete_jqueryui.js');
  }
}