Posted by minde66 on November 14, 2007 at 7:46pm
15 followers
Jump to:
| Project: | Automatic Nodetitles |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (works as designed) |
Issue Summary
Token does not work for me with Automatic Nodetitles even for the most simple case, when i just write [nid] in 'Pattern for the tittle' - it return no title. When i add some text, it returns text but no token value from node variable. I use custom node type created with CCK. I am using latest versions of both - Token 5.x-1.9 and Automatic Nodetitles 5.x-1.1 (downloaded today) and Drupal 5.3. I am completely lost - what I am doing wrong? Thank you very much.
Comments
#1
some of the tokens won't work during node creation. such as [nid] just because the node hasn't been created, so there is no nid.
[user-id] and such work though. :/
#2
#3
Automatically closed -- issue fixed for two weeks with no activity.
#4
Sorry to open a closed issue, but I'm not sure that was the correct end to the issue.
I now understand that while many tokens as supplied by the token module will work, some will not.
Eg Nid is not available, nor is the taxomony term
[term] Name of top taxonomy term.
So there are 3 possible solutions:
1. Change the order of when Automatic Nodetitles does its work, such that those tokens become available for it to use
[Probably very difficult]
2. Reduce the set of token displayed as available for use. EG Remove [nid], [term] form the list of tokens.
Again, this is problematic, as any module can supply a token, how would Automatic Nodetitles which ones would work, and which would not.
3. Document the issue.
The readme file is already excellent, so perhaps just adding a line that some tokens may not be available would be suitable.
Thanks for the great work,
Regards
Alan
#5
To Clarify
These tokens are unavailable on Node creation
They become available on node editing.
Regards
Alan
#6
Right, this should be mentioned in the README.
So a patch for 3) would be welcome.
#7
#8
It's weird cause using some fields like content taxonomy or other cck fields, or even the original node submission do work, so why is it that some fields work, but not some others ?? Would be nice if we could use term name and such in the auto node title, otherwise it's a little difficult to use...
#9
Hi,
I can explain why auto node title doesn't work for nid, but this may not explain why all other token values are not yet available during node creation.
Essentially, nid is not available during node creation because of the way Drupal core 5.x is written. There is no module hook between the time when a to-be-created node is assigned it's nid and the time when the node is actually saved to the database.
These two events occur in the same Drupal function (it's node_save() if you're curious).
Auto node title works by hooking into a node_submit hook, which is invoked before the node_save. At this point, the new node's nid has not been assigned yet.
#10
Is there any token one could use to generate a unique title for every node?
If i could just get a num which i would be certain that it's unique i could play with the rest of the available tokens to construct a nice unique title..
#11
Probably I've similar problem in Drupal 6.x.
When I'm creating node (using user_register form with content_profile module), the title is not generated.
Followed callback is not call after submit:
$form['#submit'][] = 'auto_nodetitle_node_form_submit';It's the same issue?
How to fix that?
#12
@kenorb: no, it's another issue see http://drupal.org/node/325280
#13
This is still an issue somehow. I don't understand why tokens that don't work are listed as an option, e.g none of the datestamp tokens work either. Even updating path auto afterward doesn't seem to work. Is there a working list of tokens that are available at node creation?
Regards,
Marius
#14
Apologies....I mistakenly used wrong syntaxing...ahem...date tokens work fine. Still wish top term could be parsed at node creation.
Regards,
Marius
#15
Ditto.
#16
This is not really an automatic node titles issue, but a factor of how Token works. You can use PHP in the field (it's pretty much the same as grabbing the term for a theme function), which works better to boot.
#17
subscribing
#18
You may try solution by defining following hook in your custom module:
<?php/**
* Implementation of hook_nodeapi().
*/
function hook_nodeapi(&$node, $op) {
switch ($op) {
case 'alter':
$node->title = token_replace_multiple($node->title);
break;
}
}
?>
I haven't tested it, so you may try to change 'alter' to something like 'presave' and can add additional condition to apply token only for specified content types.
#19
subscribe... would like to see this available too...
#20
I just thought I would throw in a quick workaround to the problem. Using Rules you can apply the title after the node has been created when such items as nid are available.
#21
To drseussofporn: thank you for the wonderful idea!
I have created a Triggered Rule for the event "After saving new content" with the token [node:nid].
It works like a charm, no more overlapping node titles and no more database queries for Automatic Nodetitles. Woohoo, tnx!