I have been in a few situations where I needed node titles generated automatically, but only when the node is created, not when it is edited. I tried to use an if-else structure in the evaluated php code, but I haven't managed yet to pull the node title out of $form_values because it is already temporarily set to 'ant'. From looking at the code it seems that it shouldn't be too hard to add an option to bypass the automatic title generation on node edit for certain content types (that would be another checkbox on the content type settings page), and it would definitely be cleaner doing this in the back-end than in the admin front-end.
I should be able to write this functionality and submit a patch, but before I start coding I was wondering if I could get your opinion/concerns/suggestions about how to go about this.
Comment | File | Size | Author |
---|---|---|---|
#53 | 171249-53.patch | 4.5 KB | anmolgoyal74 |
#29 | ant_prsrv_title.patch | 4.46 KB | clivesj |
#14 | ant_preserve_option.patch | 3.12 KB | clivesj |
#11 | auto_nodetitle_preserve_title_d5.patch | 4.15 KB | dagmar |
Comments
Comment #1
olio CreditAttribution: olio commentedYeah! Please, please, please try this! I ran exactly into this kind of problem some time ago and I wasn't able find a solution to it. Unfortunately, I posted this issue in the wrong thread (and didn't get a reaction) because I thought it has something to do with another module (AHAH Framework). Here is the link to this issue: http://drupal.org/node/154157 (please tell me if you need more information)
Up to now I was forced to hardcode some node titles inside node template files to hide the famous 'ant' titles - not so elegant...
The Automatic Nodetitle module is great and I can't imagine how to live without it anymore ;o).
So your efforts in finding a solution to this problem would be really, really appreciated.
Thanks!
Comment #2
fagoyep, a patch for this would be great. But please write it that way, so that people could also use it the other way round: only automatic set the title on node update, e.g. by using two checkboxes. And if necessary, don't forget an upgrade path so that no settings are lost!
Comment #3
ellanylea CreditAttribution: ellanylea commentedsubscribing
Comment #4
markfoodyburton CreditAttribution: markfoodyburton commentedI'd like this too - actually, I dont see why this isn't the default...?
Why would you want the title changed on an update - except that it's the only way to get the token stuff working, which is a little awkward anyway?
Comment #5
gmak CreditAttribution: gmak commentedI'd like to add my voice to the call for auto node title on insertion (and update)
Comment #6
grah CreditAttribution: grah commentedsubscribing.
Comment #7
fagothe optional title generation feature already allows a similar behaviour, for more look at:
http://drupal.org/node/198398
Comment #8
marcoBauli CreditAttribution: marcoBauli commentedactually looking for the same thing. happy to test any early patch if available.
Comment #9
clivesj CreditAttribution: clivesj commentedBecause I needed this very badly I editted the module to suit my needs.
It is a very dirty sollution so it is not fit for a patch or anything.
If ANT detects the title is already set (like when updating a node created before) it will by-pass the title generator.
Of course you will loose token-generated updates of your title, but for me this works better.
Use at own descrition. The parts I changed are commented // *** Clivesj edit
When I have time i will propose a generic sollution.
Comment #10
cs8c CreditAttribution: cs8c commentedclivesj, Thank you for this dirty fix, it works great so far!
Comment #11
dagmarI have created a patch based on clivesj code that adds another option to auto node titles settings.
It allows to select if preserve or not the original title of the node.
Comment #12
fagoHm, I had not planned to add new features to the 5.x branch, but if you roll a 6.x patch too I'm ok with that.
@patch:
* please add your option just as another radio field - as it's just another possible way the module can work. Allowing the combination of the options makes it to difficult to grasp.
* be sure to prefix your variables with ant_ like the other variables.
* I've done some changes in CVS, please reroll your patch and add your new variable to the uninstallation procedure and hook_node_type()
Comment #13
revimage CreditAttribution: revimage commentedWoah hang on people... can we ask that this feature be OPTIONAL?
For myself actually... i would prefer if it does constantly check for a change on updates... i am using the token [menu-link-title] to have auto nodetitle automatically title the page to whatever is set for the menu name, but MORE importantly... my content type utilizes another module to automatically insert that SAME value into Taxonomy for other uses... so if the title of the page doesnt change, neither will my taxonomy term which could break a big part of how my drupal config is working.
Sincerely hope that makes sense.
Best,
Mike
Comment #14
clivesj CreditAttribution: clivesj commentedThis patch
I have prepared a D6 version, but will open a seperate issue to provide the patch as soon this one is found OK.
I suggest not to "hide" but "disable" the node-title. This provides the possibility to add some info to the user so they know what behavior to expect.
I have changed an if-loop to a switch-loop for clarity.
Comment #15
benkallos CreditAttribution: benkallos commentedPatch failed against version 6.x-1.2.
Perhaps it can get rolled into the latest DEV version?
Perhaps a fourth option should be offered for "hide"?
Switch loop did improve clarity.
% patch -b < ant_preserve_option.patch
patching file auto_nodetitle.module
Hunk #2 FAILED at 28.
Hunk #3 succeeded at 88 with fuzz 1 (offset 10 lines).
Hunk #4 succeeded at 167 (offset -2 lines).
1 out of 4 hunks FAILED -- saving rejects to file auto_nodetitle.module.rej
Comment #16
clivesj CreditAttribution: clivesj commentedHello,
The patch was for D5.
Since I don't need this feature anymore, I have abandoned efforts for this patch.
Greetz
Comment #17
dagmarOk, lets move this to "active" again. I will to try to make a patch for 6.x this week.
Comment #18
klonosI need this feature badly too.
If I get this right, the way we are trying to work around this is to have an extra option in the node edit form that will bypass the title update if a title is already set(?), something like say... a 'Don't update title' checkbox? If so, can we please also have a default setting for this? I mean an option in the content type creation page.
@Dagmar: did you make any progress on the patch? I don't mean to bother you, I simply need a status update and if you have a draft patch perhaps I can help test it.
Thanks in advance.
Comment #19
stoinov CreditAttribution: stoinov commentedsubscribing - need that one too.
Comment #20
FiNeX CreditAttribution: FiNeX commented+1
Comment #21
Anonymous (not verified) CreditAttribution: Anonymous commentedAny news? This is a major issue for many of us yet seems to be getting no attention
Comment #22
AdrianB CreditAttribution: AdrianB commentedSubscribing.
Comment #23
powery CreditAttribution: powery commentedsubscribe
Comment #24
clivesj CreditAttribution: clivesj commentedOK folks, I´m not using this option myself, but I changed the module (D6) to accomodate this change.
With ANT enabled you will have an extra option:
So after node creation ANT will not modify the title anymore.
Also when creating an ANT-enabled node, the title-field will not be hidden. It will show a description of how the title generation will occur.
Please test this version on your test-site and please provide feedback. If it´s OK I will make a patch.
Greetz
Comment #25
andrey_ts CreditAttribution: andrey_ts commentedI have similar problem. When creating a new node, the title is being generated well, but when I try to edit this node, title becomes empty. The title is supposed to be in following form: '[parent-title] by [field_developer-formatted]' where [parent-title] is token returned by Node Relativity module.
My solution is to use code in "Automatic title generation" settings:
Comment #26
clivesj CreditAttribution: clivesj commentedAndrey, I think yours is a different thing.
This issue is about a feature to preserve a title once it is generated. The need for preserving the title is NOT -as in your case- the generated title disappears, but because it it re-generated when the node is edited.
The re-generation is normal system operation by design.
What we are trying to do now is to create an option to choose whether you want to title to be regenerated or not.
Comment #27
andrey_ts CreditAttribution: andrey_ts commentedYep, I got. It's different a bit, yes, but anyway return result we need.
Comment #28
FiNeX CreditAttribution: FiNeX commentedI've tried the code from comment #24 but it simply doesn't work (I've ported the changes to the current -dev release). The title is ever updated.
Comment #29
clivesj CreditAttribution: clivesj commentedForget # 24, it has a bug in it.
I have corrected it and tested it on my test environment.
The patch will add a 3th option to ANT: Generate a title, but don't update it once it is generated.
It will also give a description on the node entry form, so you know what is happening with the title.
I have included some screenshots so you can see how it works:
Notes:
Comment #30
klonosA minor typo that I saw in the screenshots and verified that exits in the patch's code:
...Title for this node will be set automatically bij ANT module...
should be:
...Title for this node will be set automatically by ANT module...
I have a suggestion. It would be really useful if there was a per-node option to allow changing of the title in cases where required, perhaps only by certain roles. What I am talking about is:
1. Change the setting's (radio button) text from:
Always automatically generate the title but preserve the first generated title
to:
Always automatically generate the title and lock it so it cannot be changed on edit
2. Add a 'Unlock automatically generated node titles' permission.
3. Add a 'Unlock title' checkbox under node's locked titles that will *only* show for roles/users with the permission.
This way, certain roles would be able to temporary unlock the title, edit it and once the node is saved the new title would still have a locked state.
Comment #31
clivesj CreditAttribution: clivesj commentedI 'll correct the typo, thanks.
I think it is a good suggest to be able to unlock a locked title. But in order not to complex the code to much it may be easier to add a disengage button for ANT alltogether. Indeed ruled by permission. So those with permission can always overide a title regardless of the node-option.
But we we will have to discuss this with fago since he has no intention to allow new features to ANT
Comment #32
klonosFair enough, but even if there's no intent to add new features, still a solution here as a patch would help a lot of people get things done. Thanx for considering my suggestion and for your time on this Clivesj.
Comment #33
FiNeX CreditAttribution: FiNeX commentedOk, now the patch looks correct.
Does the intent to not add new features include the generation of the title only when the node is created (this topic) ?
Comment #34
klonos@FiNeX: As Clivesj already said in #29 (his note #1) the module's development status is set to 'Maintenance fixes only'. You can see this for yourself in the project's page. I guess this means that there will be no new features whatsoever ...unless of course fago doesn't intent to be that strict about it ;)
Comment #35
FiNeX CreditAttribution: FiNeX commented@Klonos: sorry, I didn't read well the notes :-) Thanks :-)
Comment #36
klonosNo problem mate ;)
Comment #37
flirpkrahusel CreditAttribution: flirpkrahusel commented@clivesj
just want to say thanks for your great patch!!
Comment #38
clashar CreditAttribution: clashar commentedwhat would be solution for D7?
Comment #39
fagonew features should go in 7.x first.
>Maintenance fixes only
That means I'm not going to actively work on new features. But if the community comes up with new stuff that is wanted and fits in the module, like this one - I'm fine with that!
Comment #40
clivesj CreditAttribution: clivesj commentedI have a patch for D7, but I'm trying to figure-out how to file a patch utilizing the new GIT system
Comment #41
christopherreay CreditAttribution: christopherreay commentedProper patches with GIT
This article should be everywhere
http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/
Christophler
Comment #42
clivesj CreditAttribution: clivesj commentedThanks Christopher,
That was really usefull.
I have created a patch for D7 http://drupal.org/node/1225384 and will come-up with a backport for D6 shortly.
Comment #43
iex CreditAttribution: iex commentedThere is a problem in 6.x patch.
When using "image import", the module generates EMPTY TITLE. Title is correctly generated only if the node is created thru node/add/image.
Is there a quick way to fix this? When patch was not applied title was generated correctly.
Please help.
Comment #44
clivesj CreditAttribution: clivesj commentedHi Lex, are you using patch #29? If so, what is shown in the title field when editing the node?
Comment #45
puddyglumPatch from #42 had some problems: http://drupal.org/node/1225384#comment-4927390
The link includes what I did to fix it.
Comment #46
bmango CreditAttribution: bmango commentedI managed to only update the node title on insertion and not on update by using the following code in the ANT code area:
I didn't need to patch the module.
Comment #47
Seifbh5 CreditAttribution: Seifbh5 commentedHey,
I already updated and tested the code on my own project , and that's work ..
' . $code);
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/**
* Implements hook_node_type().
*/
function auto_nodetitle_node_type($op, $info) {
switch ($op) {
case 'delete':
variable_del('ant_' . $info->type);
variable_del('ant_pattern_' . $info->type);
variable_del('ant_php_' . $info->type);
break;
case 'update':
if (!empty($info->old_type) && $info->old_type != $info->type) {
variable_set('ant_' . $info->type, auto_nodetitle_get_setting($info->old_type));
variable_set('ant_pattern_' . $info->type, variable_get('ant_pattern_' . $info->old_type, ''));
variable_set('ant_php_' . $info->type, variable_get('ant_php_' . $info->old_type, ''));
variable_del('ant_' . $info->old_type);
variable_del('ant_pattern_' . $info->old_type);
variable_del('ant_php_' . $info->old_type);
}
break;
}
}
?>
Enjoy
Comment #48
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedThis patch will solve the issue.
In Hook_node_presave, I have added the condition for checking whether a node is being updated.
Comment #49
Utkarsh_Mishra CreditAttribution: Utkarsh_Mishra at OpenSense Labs for DrupalFit commentedComment #51
gaurav.kapoor CreditAttribution: gaurav.kapoor commentedComment #52
dagmarThanks @gaurav.kapoor, but I would like to ask you some moments to review what you just did. I contributed the first patch for this issue, nine years ago. There was a lot of discussion in the mean time. Now, you committed and pushed a patch that was created by someone of your own company, reviewed by another member of your company as RTBC (even when this patch has, at least, coding standards issues) and then committed and pushed in less than 24hs.
Also, I may be wrong but I think the committed code basically do a totally different thing than expected, because the issue summary says:
The logic you committed doesn't seems to do what is intended. Actually it seems it does just the opposite. It updates the title if there was something there already, so it will be update twice the title (see auto_nodetitle_set_title). Also, probably will trigger notices for each node saving since is not using
empty()
.Again, I'm glad this issue is having progress again and happy to see you contributing, and I understand anyone can have bugs in their code. What I'm trying to say is please, try to get reviews from others developers outside your own company to get an approval. This module is used by 50K sites around the world.
Thanks!
Comment #53
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commented@dagmar, I have not interpreted the issue correctly.
I have now used the solution provided by you and @clivesj.
Please tell if I'm missing any case.
Comment #54
gaurav.kapoor CreditAttribution: gaurav.kapoor commented@dagmar. Thanks for the review. We will rework on this issue and check all the aspects. This module has been inactive for a long time and there are many duplicates for a similar issue. @anmolgoyal74 and @Utkarsh_Mishra are handling all the issues, they both are new to Drupal and are trying their best to understand the process of problem-solving and issue credit in Drupal. Now that you have brought to notice, I'll review all there patches and then only commit.
Thanks.
Comment #56
manish-31 CreditAttribution: manish-31 at OpenSense Labs for DrupalFit commentedThis is not an issue for 7.x-1.x and it works as designed.