I am having titles generated when the title field is empty. I am using:

[term-raw] vs. [field_opponent-raw]

When I first save the node, the title is " vs. Cecil County"

If I then delete this title and save again I get the correct "Women's Basketball vs. Cecil County"

Any thoughts? Thanks.

CommentFileSizeAuthor
#1 auto_nodetitle.term_raw.patch677 bytesjhedstrom
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhedstrom’s picture

Status: Active » Needs review
FileSize
677 bytes

The attached patch resolved the problem for me. However, it is somewhat of a hack, as the root cause of this lies further down the token module chain.

trofimchouk’s picture

Thanx for the patch, but there is an error.

Instead of
+ foreach ($node->taxonomy as $tid => &$term) {
+ $term = taxonomy_get_term($tid);

Shoould be
+ foreach ($node->taxonomy as $count => &$term) {
+ $term = taxonomy_get_term($term);

tannerjfco’s picture

I have this problem using the formatted [term] value as well, should that make any difference. Looks more to be a token/taxonomy issue.

tannerjfco’s picture

This patch doesn't appear to work quite right. It will add a term to the title, but it's not the term that I applied to the node... it's not even a term in the same Vocabulary. I tried it with the change posted by lancelot, and the patch ceased to have any effect whatsoever.

a.a.egoroff’s picture

EPIC FAIL:)
This patch converts (int) $term to (obj) $term… Vocabularies' fields become blank:) when node edit form refreshes e.g. on preview or on form validation error. It seem like core Token bug, not ANT.
Try this #338853: Token malfunction with Auto NodeTitle: [term] replacement fix patch — works for me:
D6.13
CCK 2.4
Views 2.6

tannerjfco’s picture

a.a.egoroff, that patch did the trick! Thanks!

jhedstrom’s picture

Status: Needs review » Needs work
fripplo’s picture

I solved it by changing the order of module priority; the "Token" module needs to do it's work before "Automatic Nodetitles". This is how I did it:

1. Dowloaded, installed and activated "Module Order": http://drupal.org/project/module_order .
2. Added "after = token" (ex the quotationmarks) to /sites/all/modules/auto_nodetitle/auto_nodetitle.info according to instructions.
3. Went to "Administer > Site Configuration > Module Order" and pressed button "Rebuild Module Weights".

This worked fine for me. Don't really know if step 2 would make any difference or not (all module weights were rebuilt and wighted depending on their alphabethical position).

Note that "Module Order" is in dev. Don't forget to make backup your site before you try.

alliax’s picture

For me this module_order messed up my cck form because it changed ALL module weight in system table, and I have wasted so much time to find out that it was this action that messed it up.
And thanksfully I had a backup of my database from one day before, so I have been able to make a sql query to reset all module weight the same way as before.

MODULE_ORDER = NEVER AGAIN !

If I want to mess up with module order I will take a module which doesn't set all modules weight when I only want one module to be above another one. This is crap, I'm furious about doing this and wasting my time just to be back with my initial problem, but I'm happy that I have been able to find and solve the mess created by module_order otherwise I would be in a much more trouble than I am now with my small problem.

Now I will try to find another module to set the module weight (or maybe I should simply do it in the database instead of relying on a module which does what it wants)

sorry for the rant.

jeffreyvddb’s picture

So... What is the right way to do this? The patch isn't working and the module 'Module Order' is messing up databases.. Any suggestions?

bdimofte’s picture

Well, you can set the weight yourself in the database.

Or better yet, write the query in a module's install file:

function YOUR_CUSTOM_MODULE_install() {
  $items = array();
  $weight_array = db_fetch_array(db_query('SELECT weight FROM {system} WHERE name = "token"'));
  $weight = $weight_array['weight'] + 1;
  $items[] = update_sql( 'UPDATE {system} SET weight = '.$weight.' WHERE name = "auto_nodetitle";' );
  drupal_set_message('The weight of the auto_nodetitle module has been set.');
  return $items;
}
jeffreyvddb’s picture

I changed the weight of the auto_nodetitle to 11. Token has weight 10. On submission of a new node, the title still isn't generated.
Because the fields come from the 'Location', which is another module, I changed the weight of all the .module files related to 'Location' to 12. But still no result.. Tried to clear the cache, but that didn't work either. Any suggestions?

nlambert’s picture

subscribing

alexbk66-’s picture

subscribing

P.S. To change module weight use Util module http://drupal.org/project/util, it's Drupal, remeber?

alexbk66-’s picture

Actually, this is duplicate issue, but the other one does have a workaround:
http://drupal.org/node/373978#comment-1654702

aubjr_drupal’s picture

Go to my summary on available hacks/fixes as of this posting for this problem. I put it together after coming across a lot of posts on this issue and wanted to summarize it for others.

gaurav.kapoor’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)