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.

(1) #194197: Use (T)NID as node title

Comments

threexk’s picture

Component: Code » Documentation
SpikeX’s picture

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

Stomper’s picture

I'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

fourmi4x’s picture

You can do this quite easily with Rules module.

Stomper’s picture

True, 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.

fourmi4x’s picture

Follow these steps :

Content type
0. Put " return 'MyContentType - ' . '[nid]' " in the automatic nodetitle configuration of your content type

Rules
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!

asb’s picture

@fourmi4x (#6): Thanks, this Rules-based approach works for me (though it is quite a lot of overhead just to generate a proper nodetitle ;)

fago’s picture

Status: Active » Fixed

Makes sense. I've added such a note to the README of 6.x and 7.x

Stomper’s picture

Will have a go, will report back.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.