You are here

function word_link_words_autocomplete_callback in Word Link 7.2

Autocomplete callback for words by text.

Parameters

string $string: The string that will be searched.

1 string reference to 'word_link_words_autocomplete_callback'
word_link_menu in ./word_link.module
Implements hook_menu().

File

./word_link.module, line 788

Code

function word_link_words_autocomplete_callback($string = "") {
  $matches = array();
  if ($string) {
    $result = db_select('word_link', 'wl')
      ->fields('wl', array(
      'id',
      'text',
    ))
      ->condition('text', db_like($string) . '%', 'LIKE')
      ->range(0, 10)
      ->execute();
    foreach ($result as $word) {
      $matches[$word->text . " ({$word->id})"] = check_plain($word->text) . " ({$word->id})";
    }
  }
  drupal_json_output($matches);
}