Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.509 diff -u -F^f -r1.509 node.module --- modules/node.module 20 Jul 2005 10:48:20 -0000 1.509 +++ modules/node.module 26 Jul 2005 17:51:14 -0000 @@ -656,6 +656,11 @@ function node_menu($may_cache) { 'access' => user_access('access content'), 'type' => MENU_ITEM_GROUPING, 'weight' => 1); + + $items[] = array('path' => 'node/autocomplete', 'title' => t('autocomplete node'), + 'callback' => 'node_autocomplete', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK); } else { if (arg(0) == 'node' && is_numeric(arg(1))) { @@ -1984,4 +1989,17 @@ function node_db_rewrite_sql($query, $pr * @} End of "defgroup node_access". */ +/** + * Helper function for autocompletion + */ +function node_autocomplete($string) { + $matches = array(); + $result = db_query_range(db_rewrite_sql('SELECT title FROM {node} WHERE LOWER(title) LIKE LOWER("%%%s%%")'), $string, 0, 10); + while ($node = db_fetch_object($result)) { + $matches[$node->title] = check_plain($node->title); + } + print drupal_implode_autocomplete($matches); + exit(); +} + ?>