Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | node_autocomplete_0.patch | 1.26 KB | Bèr Kessels |
node_autocomplete.patch | 1.25 KB | Bèr Kessels | |
Comments
Comment #1
Bèr Kessels CreditAttribution: Bèr Kessels commentedthis one adds rewrite sql :)
Comment #2
chx CreditAttribution: chx commentedand so gets a +1 from me.
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedHow do you see this being used?
I wonder if developers will want further restrictions on returned nodes like type=x, for example.
Comment #4
Bèr Kessels CreditAttribution: Bèr Kessels commentedfrom 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.
Comment #5
killes@www.drop.org CreditAttribution: killes@www.drop.org commentedI 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();
}
Comment #6
Bèr Kessels CreditAttribution: Bèr Kessels commentedah, then I misundersood. yes a big +1 for that feature.
Comment #7
Bèr Kessels CreditAttribution: Bèr Kessels commentedneeds work to putn in Gerhards idea.
Comment #8
Uwe Hermann CreditAttribution: Uwe Hermann commentedPatch doesn't apply anymore. I like the idea, though.
Comment #9
Bèr Kessels CreditAttribution: Bèr Kessels commentedMe too. Yet ,there were people who disliked such an API-only function (as in: not used in core, only providing a possible use). I have a new and improved API for this in clipper.module.
Comment #10
moshe weitzman CreditAttribution: moshe weitzman commentedComment #11
Boris Mann CreditAttribution: Boris Mann commentedfreelinking does this, so perhaps look at that code, as well as the wiki module code.
Comment #12
bdragon CreditAttribution: bdragon commentedThis is a feature that belongs in contrib.
Anyway, it's already implemented in http://drupal.org/project/auto_nodetitle .