function ckeditor_link_autocomplete in CKEditor Link 7
Same name and namespace in other branches
- 6.2 ckeditor_link.module \ckeditor_link_autocomplete()
- 6 ckeditor_link.module \ckeditor_link_autocomplete()
- 7.2 ckeditor_link.module \ckeditor_link_autocomplete()
1 string reference to 'ckeditor_link_autocomplete'
- ckeditor_link_menu in ./
ckeditor_link.module - Implementation of hook_menu().
File
- ./
ckeditor_link.module, line 38 - Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr> http://www.absyx.fr
Code
function ckeditor_link_autocomplete($string = '') {
$matches = array();
if ($string !== '') {
$query = db_select('node', 'n')
->fields('n', array(
'nid',
'title',
))
->condition('n.title', '%' . $string . '%', 'LIKE')
->orderBy('n.title')
->orderBy('n.type')
->range(0, 10)
->addTag('node_access');
$result = $query
->execute();
foreach ($result as $node) {
$matches[$node->title . ' (node/' . $node->nid . ')'] = '<div class="reference-autocomplete">' . check_plain($node->title) . '</div>';
}
}
drupal_json_output($matches);
}