ANT should generate the node.title on hook_nodeapi($op = 'validate') to make generated node titles available for other modules.

Use case: a client wants to be able to highlight some terms in node titles, which is done by the means of a CCK textfield, FCKeditor and ANT. ANT cleans off all the HTML tags from the mess that FCKeditor spits into the CCK field, so the browser's title bar will not get messed with HTML (the highlighted version will be used in the page by some theming magic). So far so good, but the client wants to make use of unique_field.module (UF) to prevent multiple nodes with the same cleaned title (in other words: he wants "foobarbaz" and "foo<em>bar</em>baz" considered to be the same by UF).

There are two glitches with that.

1. It must be ensured that the UF's validator gets called after ANT generates the title, ie. unique_field.module should have greater weight than auto_nodetitle.module, since both are utilizing hook_nodeapi().

2. Since ANT generates the node.title in hook_nodeapi($op = 'presave') which will not ever run before hook_nodeapi($op = 'validate') (that UF utilizes), UF will not be able to make decisions based on cleaned (ANT-generated) node titles.

This is where my attached patch kicks in: ANT should generate the node.title even in hook_nodeapi($op = 'validate'), so UF will be able to make use of it (after some weighting of modules). Since ANT makes sure that it is generating node.title only once, it is not a problem to (try to) run the auto-generation code in both (validate and presave) steps. Anyway, I have not encountered any glitches caused by this modification.

CommentFileSizeAuthor
#1 auto_nodetitle-validate.patch725 bytesBoobaa
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Boobaa’s picture

FileSize
725 bytes

Ohmy, gnomes have stolen my patch (again).

gagarine’s picture

#160816: "ant" instead of [title] when using auto node title is certainly linked to that...

For me "ant" also appear with rules if I use Updated content values.

gagarine’s picture

Mmmmh I can't try your patch because I use already the patch http://drupal.org/node/194197#comment-1936310 (Use NID as node title)

EDIT I post a patch on the issue to resolve this problem too http://drupal.org/node/194197#comment-2759532

fago’s picture

Status: Needs review » Closed (won't fix)

We already provide it rather early (form_submit), but changing values during validation is not good. There might be wrong validated values, thus using them is a no go.