Issue status update for http://drupal.org/node/27530 Post a follow up: http://drupal.org/project/comments/add/27530 Project: Drupal Version: cvs Component: node system Category: tasks Priority: normal Assigned to: Bèr Kessels Reported by: Bèr Kessels Updated by: Uwe Hermann Status: patch (code needs work) Patch doesn't apply anymore. I like the idea, though. Uwe Hermann Previous comments: ------------------------------------------------------------------------ Tue, 26 Jul 2005 17:41:13 +0000 : Bèr Kessels Attachment: http://drupal.org/files/issues/node_autocomplete.patch (1.25 KB) This patch introduces an autofill for node titles. It is not yet used anywhere, but at least we have the node/autofill url available where contribs &c can query for node titles. ------------------------------------------------------------------------ Tue, 26 Jul 2005 17:52:59 +0000 : Bèr Kessels Attachment: http://drupal.org/files/issues/node_autocomplete_0.patch (1.26 KB) this one adds rewrite sql :) ------------------------------------------------------------------------ Tue, 26 Jul 2005 18:09:04 +0000 : chx and so gets a +1 from me. ------------------------------------------------------------------------ Tue, 26 Jul 2005 18:18:13 +0000 : moshe weitzman How do you see this being used? I wonder if developers will want further restrictions on returned nodes like type=x, for example. ------------------------------------------------------------------------ Tue, 26 Jul 2005 19:54:23 +0000 : Bèr Kessels from the top of my head: * a search. * the book-parent selector * clipper.module (node-node relations) * anywhere else where you need to select a single node. About the types: I thought about that for a few seconds, but thought it: * OTT. this works perfectly fine. Whenever the need for a type subselector appears, it can still be added. * userunfriendly. users should not have to bother about node types. So, it was intentional that I left out types. Oh, And i am aware of any restrictions when there are a /lot/ of nodes. youwill get a lot of nodes with similar titles. But that is a general problem, which occurs in freetagging and user autofill just the same. ------------------------------------------------------------------------ Tue, 26 Jul 2005 20:18:35 +0000 : killes@www.drop.org I don't think that Moshes wanted the user to make this the selection, but the programmer that calls this function. Event.module would want to only get titles for node types that are event enabled, etc. I suggest an optional second argument to the function, that accepts a comma delimited string. thus you could search in all node titles that have node types that occur in that string. function node_autocomplete($string, $node_types = NULL) { $matches = array(); if ($node_types) { $result = db_query_range(db_rewrite_sql('SELECT title FROM {node} WHERE type IN ('%s') AND LOWER(title) LIKE LOWER("%%%s%%")'), %node_types, $string, 0, 10); } else { $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(); } ------------------------------------------------------------------------ Tue, 26 Jul 2005 20:55:19 +0000 : Bèr Kessels ah, then I misundersood. yes a big +1 for that feature. ------------------------------------------------------------------------ Tue, 02 Aug 2005 18:49:46 +0000 : Bèr Kessels needs work to putn in Gerhards idea.