You are here

function site_disclaimer_autocomplete in Site Disclaimer 7

Same name and namespace in other branches
  1. 6 site_disclaimer.admin.inc \site_disclaimer_autocomplete()

Helper function for autocompletion

1 string reference to 'site_disclaimer_autocomplete'
site_disclaimer_menu in ./site_disclaimer.module
Implements hook_menu().

File

./site_disclaimer.admin.inc, line 349
Administration settings for Site Disclaimer module.

Code

function site_disclaimer_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);
}