function _disclaimer_node_autocomplete in Disclaimer 7
Autocomplete helper for nodes search.
Parameters
string $string: String for search.
1 string reference to '_disclaimer_node_autocomplete'
- disclaimer_menu in ./
disclaimer.module - Implements hook_menu().
File
- ./
disclaimer.module, line 374 - Create and show disclaimer for your site.
Code
function _disclaimer_node_autocomplete($string = "") {
$matches = array();
if ($string) {
$result = db_select('node')
->fields('node', array(
'nid',
'title',
))
->condition('title', db_like($string) . '%', 'LIKE')
->range(0, 10)
->execute();
foreach ($result as $node) {
$matches[$node->title . ' [' . $node->nid . ']'] = check_plain($node->title);
}
}
// Return the result to the form in json.
drupal_json_output($matches);
}