Closed (outdated)
Project:
Automatic Nodetitles
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Mar 2011 at 20:29 UTC
Updated:
13 Jun 2018 at 07:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
SpikeX commentedIt's only when you first save a node. If you go back and edit the node, and then re-save it, the value will work. I suspect this has something to do with the "nid" value not being accessible when a node is first created.
Comment #2
christopherreay commentedI have created a patch that "fixes" this.
The patch is dirty, and evil. It causes the Node to be saved twice on the initial save, much like it is suggested that one does.
As it looks like, Spike you are doing something similar to me (in fact your php is almost exactly the same, looks like an invoice reference to me) then you might want to try this patch. The patch also "works" with pathauto, which is nice.
THIS PATCH IS NOT WELL THOUGHT OUT. THOUGH IT WORKS FOR ME, IT MIGHT CAUSE SOME WWIIEERRDD SIDE EFFECTS. So be careful with it and check its not doing wierd things
Oh, the patch is for the 6.x-1.2 version of this module.
Comment #3
christopherreay commentedoh, some tags...
Comment #4
inforeto commentedIs insert run before or after the original save?
Is there any kind of post save op to the nodeapi hook?
Comment #5
cliffordx commentedsubscribe! I used nid for my auto node title by it does not show up the nid. I need to edit and save it again in order to work. This doesn't happen when I first install auto_nodetitle. I suspect it's conflicting with either of these plugin that I later added:
field_permissions
locationmap
image_url_formatter
token (release update)
Comment #6
seddonym commentedThis is how I got around the issue in Drupal 7:
Comment #7
nicholas.alipaz commentedI have written a patch for this. The issue is that the $node->nid is not yet created when saving a node for the first time, however in all other saves the $node->nid is available. To bypass the issue there is really only one solution that I can think of and that is to:
If the nid is NOT set then we wait to do our
auto_nodetitle_set_title($node);since this means we are in the initial creation of a node.Instead we will wait until the insert $op where the $node->nid will be set and then we do
auto_nodetitle_set_title($node);then resave the node.This means the very first time that we save the node that we actually do two saves, which is not very resource friendly, but it is the only real solution.
The only thing I might do to make this patch better is to add a checkbox setting in the content type that says something like, "I have used the $node->nid or a token that is dependant on the node nid in my title pattern." When checking the box we would do the double save, otherwise we could just do everything in presave as the module currently does.
Comment #8
nicholas.alipaz commentedComment #9
nicholas.alipaz commentedHere is a version of the patch with the additional setting for turning on the setting per content type as I described in #7.
Comment #10
nicholas.alipaz commentedoops, logic was backwards in the presave op of hook_nodeapi. Fixed and new patch attached.
Comment #11
nicholas.alipaz commentedokay, one last pass at this. I realised one more needed condition to the logic and wanted to provide some documentation.
Comment #12
mvcsee also the related issues #823364: Add warning that nid cannot be used in node title and #194197: Use (T)NID as node title.
Comment #13
manish-31 commentedStopped 6.x-1.x-dev development.