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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bèr Kessels’s picture

FileSize
1.26 KB

this one adds rewrite sql :)

chx’s picture

and so gets a +1 from me.

moshe weitzman’s picture

How do you see this being used?

I wonder if developers will want further restrictions on returned nodes like type=x, for example.

Bèr Kessels’s picture

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.

killes@www.drop.org’s picture

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();
}

Bèr Kessels’s picture

ah, then I misundersood. yes a big +1 for that feature.

Bèr Kessels’s picture

Status: Needs review » Needs work

needs work to putn in Gerhards idea.

Uwe Hermann’s picture

Patch doesn't apply anymore. I like the idea, though.

Bèr Kessels’s picture

Me 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.

moshe weitzman’s picture

Status: Needs work » Postponed
Boris Mann’s picture

freelinking does this, so perhaps look at that code, as well as the wiki module code.

bdragon’s picture

Version: x.y.z » 6.x-dev
Status: Postponed » Closed (won't fix)

This is a feature that belongs in contrib.
Anyway, it's already implemented in http://drupal.org/project/auto_nodetitle .