You are here

function terms_of_use_autocomplete in Terms of Use 7

Same name and namespace in other branches
  1. 6 terms_of_use.pages.inc \terms_of_use_autocomplete()

Helper function for autocompletion.

1 string reference to 'terms_of_use_autocomplete'
terms_of_use_menu in ./terms_of_use.module
Implements hook_menu().

File

./terms_of_use.admin.inc, line 103
Page callbacks for the Terms of Use module.

Code

function terms_of_use_autocomplete($string = '') {
  $matches = array();
  if ($string != '') {
    $result = db_select('node', 'n')
      ->fields('n', array(
      'nid',
      'title',
    ))
      ->condition('n.title', '%' . db_like($string) . '%', 'LIKE')
      ->condition('n.status', 1)
      ->range(0, 10)
      ->addTag('node_access')
      ->execute();
    foreach ($result as $node) {
      $matches[$node->title] = $node->title;
    }
  }
  drupal_json_output($matches);
}