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.
In this thread http://drupal.org/node/171249 a new option is discussed:
ANT will create the title but will not change the title once it is created.
This is usefull if the title has to be generated only once.
Comment | File | Size | Author |
---|---|---|---|
#8 | auto_nodetitle-generate-title-only-on-insertion-not-on-update-d7-8.patch | 3.87 KB | Spleshka |
#1 | preserve_title.patch | 4.41 KB | clivesj |
Comments
Comment #1
clivesj CreditAttribution: clivesj commentedHere is a patch for D7.
It includes:
1. The new option "Preserve the title once it is created". This will have no effect on your other ANT nodes already in use.
2. Due to the extra option I changed the IF ELSE ELSIF to a SWITCH loop to prevent clutter
3 Added some description to the edit field on the node entry form so the user can see what is going on regarding the node title.
In the attached images on this node http://drupal.org/node/171249#comment-4033072 you can you see how it looks like.
Comment #2
klonosThat's great Clivesj!!!, thanx. ...but there might be cases where specific nodes might need a title change/correction. How about adding a way to override the auto-generated, to-be-preserved title. I was thinking something like:
1. A "Override to-be-preserved auto-generated node titles" permission that can be assigned only to specific roles/users.
2. A "Allow to-be-preserved titles to be overridden" checkbox in the "Automatic title generation options" fieldset that will be available/enabled only when the "Always auto-generate title but preserve first one" is selected. This will give users with the proper permissions the chance to be able to override auto-generated titles when/if required.
3. A "Override auto-generated title" button/checkbox in the node edit form that would make the title field selectable/editable again. If user enters custom text, that will be used. If they do click this "Override title" button and do not edit previous title, then a new title will be generated (à la old behavior).
What do you think?
PS: the title of this issue is to generic/vague for one to find. Also I do not understand why you started a new issue and did not post this over in #171249: Generate title only on insertion, not on update.
Comment #3
clivesj CreditAttribution: clivesj commentedAh, I forgot to fill in the title that´s why it came-up with "here is a patch for D7"
I didn't post the patch in the other thread since that is a D6 issue.
I will post the D6 patch there.
Do you (regulated by permission) want to be able to override all "ANT generated titles" whether they are preserved or not?
In this case we can add a button on the node entry form to enable this.
Maybe you want to exclude ANT title overriding for a certain node-type?
In any case I suggest to add the preserve option as per patch and start a new request for the override option. Let´s also hear Fago´s opinion on this.
Comment #4
klonosHmm... no it's not. You can switch it back to a 6.x issue (+ denote that in that issue's title with a "(D6)" similarly to what you did here), but I am afraid it's up to Wolfgang (a.k.a. fago, the module's maintainer) to decide how issues that require fixing in 7.x then backport to 6.x are handled. Usually developers like to keep their issue queue as clean (and short) as possible, so they do this in the same issue (usually 7.x first - 6.x after). That's why I asked in the first place, I don't actually mind either way.
...yes, exactly. That's why I suggested (suggestion 3 in post #2 above) that there should be a checkbox to allow this in each content type's settings page. Perhaps I should have made it more clear that I meant that this should be a per-node setting.
btw... Thank you for your hard work and time spent in this one. I really appreciate it!
Comment #5
puddyglumThe D7 patch seemed to be working at first, and then it stopped working and was acting like the "Enabled" mode.
I modified the code in two places and it works now:
Line 80-81 of the D7 patch ($node-> title == 'ant' changed to $node->title == 'ant')
changed to
And I removed this from the patch because it was re-creating the title every time (Line 71-72):
It works great now!
Comment #6
nagiek CreditAttribution: nagiek commentedIs this code going to be merged into the -dev branch?
Comment #7
nodiac CreditAttribution: nodiac commentedThanks for posting the diffs! If it works, I'll post it as a patch.
Comment #8
SpleshkaThanks for your patch, but it breaks logic for other node titles. I attached a patch that works for me.
Comment #9
nfriend CreditAttribution: nfriend commentedGreat module and nice patch - just what was needed!
#8 worked for me but only after implementing the last changes mentioned in #5 "And I removed this from the patch because it was re-creating the title every time (Line 71-72):"
The first change mentioned in # 5 is in the #8 patch.
Thanks to all!
Neil
Comment #10
klonosThe patch in #8 contains that change too (lines 56-59).
Comment #11
nfriend CreditAttribution: nfriend commentedHey Klonos - in response to #10 - Actually those lines (56-59 in #8) (71-72 in #5) , put in what number 5 says to leave out. So I removed them.
I did the #8 patch first in full but still had it being recreated each time. I saw the # 5 note, and removed the 56-59 insertion, leaving the original and it works!
At least for me.
Thanks for your help.
Neil
Comment #12
klonosok, thanx.
Comment #13
alimbert CreditAttribution: alimbert commentedWhen I remove line 56-59 I get a malformed function. Can anyone verify the exact code that needs to be moved. Line 56-59 in my patch looks like this:
56 - if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title']))) {
57 + if ($setting == AUTO_NODETITLE_ENABLED || ($setting == AUTO_NODETITLE_OPTIONAL && empty($form_state['values']['title'])) ||
58 + $setting == AUTO_NODETITLE_ENABLED_PRESERVE) {
59 auto_nodetitle_set_title($node);
Comment #14
clivesj CreditAttribution: clivesj commentedI'm willing to make a definate patch based on latest dev. But I think fago has to indicate wheter he is willing to incorporate the change. I 'm also willing to co-maintain the module. But i think it will becomd mess if we all propose changes witthout being able to merge ghem into ghe project and have them tested by the community.
I think this change enhances the modules functionality.
Edit: typo's, still have to get used to typing on a smartphone :)
Comment #15
jzornig CreditAttribution: jzornig commentedWould be nice to have. My 2c.
Comment #16
juves CreditAttribution: juves commentedThis feature is still not implemented in dev, can somebody please post a final patch?
Comment #17
clivesj CreditAttribution: clivesj commented@juves. I don't think the module maintainer wants to further develop this module. I think the intention is to switch over to:
https://drupal.org/project/auto_entitylabel
Comment #18
lostchord CreditAttribution: lostchord commented@clivejs. I'm not sure that this module solves the problem. The screen shot does not show an option to persist the original title.
@juves. The workaround I'm using is to bring the field_default_token module into the picture and create fields on the form that the user can view but cannot write using field level access control - during node creation these fields are not visible. I set the default value for these fields to be the values of the tokens I'm using in the title and then use the field values as the replacement tokens in the title. Seems to work because the value is persisted in the database rather than the token placeholder. View access for the user seems to be required. I'm not sure if this works for all possible atomic field types.
Update.
There are some race condition issues with at least Term References where the values stored as the default values in fields on the form are not picked up on the create but are picked up on subsequent edits. The raw values on the original fields on the form are picked up on the initial save so this is not a major issue.
Comment #19
Amir Simantov CreditAttribution: Amir Simantov commentedHi guys, thanks for this issue. I wanted to do the same but to let an authorized user to DO edit the title manually or to call for computing. I do not need it in the interface, so some code is enough in this case of mine. I am writing it down here both for sharing and for revision.
Comment #20
yngens2 CreditAttribution: yngens2 commentedHi,
Just to confirm the patch in #1 gave the following output in CLI:
but worked on Drupal UI perfectly well.
This request was filed four years ago and is still pending. Will this be ever committed to the official version?
Comment #21
ashzade CreditAttribution: ashzade commentedUsing latest version, I have this functionality by default: node titles created via PHP don't update, even if I want to :/ Now I can't update node titles at all. Is it because of PHP?
Comment #22
Utkarsh_Mishra CreditAttribution: Utkarsh_Mishra at OpenSense Labs for DrupalFit commentedseems like a duplicate issue, here's the link https://www.drupal.org/project/auto_nodetitle/issues/171249