Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
/**
* Autocomplete callback
*
* @param mixed $delta
* Provides the unqiue ID for the block provided by this module
* @param string $string
* The string to lookup
*/
function node_quick_find_autocomplete($delta = 0, $string = '') {
$settings = variable_get('node_quick_find_' . $delta, array());
$matches = array();
if ($string) {
$string = strtolower($string);
if (empty($settings['node_types'])) {
$result = db_query("SELECT title FROM {node} WHERE title LIKE '%s%%' LIMIT 10", $string);
}
else {
$place_holders = substr(str_repeat(",'%s'", count($settings['node_types'])), 1);
$arr = array_merge($settings['node_types'], array($string));
$result = db_query("SELECT title FROM {node} WHERE type IN ($place_holders) AND title LIKE '%s%%' LIMIT 10", $arr);
}
while ($node = db_fetch_object($result)) {
$matches[$node->title] = check_plain($node->title);
}
}
print drupal_to_js($matches);
exit();
}
Comments
Comment #1
Anonymous (not verified) commented/**
* Autocomplete callback
*
* @param mixed $delta
* Provides the unqiue ID for the block provided by this module
* @param string $string
* The string to lookup
*/
function node_quick_find_autocomplete($delta = 0, $string = '') {
$settings = variable_get('node_quick_find_' . $delta, array());
$matches = array();
if ($string) {
$string = strtolower($string);
if (empty($settings['node_types'])) {
$result = db_query("SELECT title FROM {node} WHERE title LIKE '%s%%' LIMIT 10", $string);
}
else {
$place_holders = substr(str_repeat(",'%s'", count($settings['node_types'])), 1);
$arr = array_merge($settings['node_types'], array($string));
$result = db_query("SELECT title FROM {node} WHERE type IN ($place_holders) AND title LIKE '%s%%' LIMIT 10", $arr);
}
while ($node = db_fetch_object($result)) {
$matches[$node->title] = check_plain($node->title);
}
}
print drupal_to_js($matches);
exit();
}
Comment #2
tsavino commentedI was wondering why it did not work with more then one node type.....
Comment #3
nicholasthompsonThanks Steven - I'll get this committed at some point (rather busy right now).
Comment #4
nicholasthompsonThis is fixed in D6... D5 is no longer supported.