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.
There is no plan1 to add support to Automatic Nodetitles for setting nid as part of the node title. A warning that nid and certain other fields cannot be used would be helpful to a lot of people. Many users do not understand the timing of Drupal hooks and the details of Automatic Nodetitle's implementation well enough to know that setting the nid isn't possible, and really they should not be expected to know.
Comments
Comment #1
threexk CreditAttribution: threexk commentedComment #2
SpikeX CreditAttribution: SpikeX commentedJust to clarify: The [nid] token will work, but not on first node creation. You need to edit your node and re-save it a second time for it to work.
Comment #3
Stomper CreditAttribution: Stomper commentedI've been testing used autonodetitles with nid. Requires two saves for the nid to appear. What's my other options for have a unique identifier in the title (ie. which token should I use). I'd like the token to be relatively short in length (not a hash identifier or something redic)
Also, is there any where to automatically double save a node that has nid assigned in its autonodetitles? Can this be done when cron is run? Can VBO module be used for this?
Thanks
Comment #4
fourmi4x CreditAttribution: fourmi4x commentedYou can do this quite easily with Rules module.
Comment #5
Stomper CreditAttribution: Stomper commentedTrue, and I've tried it but it doesn't seem to work. I have created a triggered where the condition is "save new node" and the action is "save node" and I've applied it to the nodes I want to resave to update auto node titles with nids in them.
I don't think the rule is working.
I wish there was a "update autonode titles" action. I'm surprised there isn't.
Comment #6
fourmi4x CreditAttribution: fourmi4x commentedFollow these steps :
Content type
0. Put "
return 'MyContentType - ' . '[nid]'
" in the automatic nodetitle configuration of your content typeRules
1. Create triggered rule "after saving new content"
2. Put a condition on the content type
3. Add an action "Load content by ID". In Content ID, put [node:nid] (if you have token module...or you can try with php)
4. Add an action "Save content" where you select the newly loaded content, and without checking "Force immediate saving."
These steps worked for me, enjoy!
Comment #7
asb CreditAttribution: asb commented@fourmi4x (#6): Thanks, this Rules-based approach works for me (though it is quite a lot of overhead just to generate a proper nodetitle ;)
Comment #8
fagoMakes sense. I've added such a note to the README of 6.x and 7.x
Comment #9
Stomper CreditAttribution: Stomper commentedWill have a go, will report back.