function autoassignrole_autocomplete_node in Auto Assign Role 6.2
Same name and namespace in other branches
- 6 autoassignrole-admin.inc \autoassignrole_autocomplete_node()
Retrieve a JSON object containing autocomplete suggestions of existing nodes.
Parameters
string $string: The search string.
1 string reference to 'autoassignrole_autocomplete_node'
- autoassignrole_menu in ./
autoassignrole.module - Implementation of hook_menu().
File
- ./
autoassignrole-admin.inc, line 391 - The autoassignrole-admin.inc file
Code
function autoassignrole_autocomplete_node($string = '') {
$matches = array();
if ($string) {
$sql = "SELECT nid, title FROM {node} WHERE status = 1 AND (LOWER(title) LIKE LOWER('%s%%') OR nid = '%d')";
$result = db_query_range(db_rewrite_sql($sql), $string, $string, 0, 10);
while ($node = db_fetch_object($result)) {
// Add a class wrapper for a few required CSS overrides.
$matches[check_plain($node->title) . " [nid:{$node->nid}]"] = "<div class=\"reference-autocomplete\">" . check_plain($node->title) . " [nid:{$node->nid}]</div>";
}
}
drupal_json($matches);
}