You are here

function ccl_node_autocomplete in Custom Contextual Links 7

Same name and namespace in other branches
  1. 8 ccl.admin.inc \ccl_node_autocomplete()

Node ID autocomplete callback function.

1 string reference to 'ccl_node_autocomplete'
ccl_menu in ./ccl.module
Implements hook_menu().

File

./ccl.admin.inc, line 378
Provides administrative functions for ccl.

Code

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