Hello all,

This is my first topic so apologies if it's in the wrong place.

I have a custom content type called 'Monthly Report', which will allow the client to upload PDF docs each month. Further to this, each document is of a specified type, such as 'Sales Report' or 'Payroll Report'.

What I want to do is assign the node title for this node type automatically, based on the document type (this is the node taxonomy term) and month (a custom field that accepts the date in the format 'January 2010'). So, if the month is entered as 'January 2010' and the taxonomy term selected for the specified type is 'Sales Report', I want the node title to be 'Sales Report - January 2010'. I do not want the node title to be editable by the end user.

Using Automatic Nodetitles I was able to achieve this using the following title pattern:

[term-raw] [field_month-view]

However, this only works when the node is updated, not when the node is created for the first time. When the node is initially created and saved, only field_month-view is used for the title.

I assume this is not working because the node does not yet know it's own taxonomy term when it reaches the auto node title code... but there must be another way of doing this. Can I get Automatic Nodetitles to use the form fields directly? What other options are there?

Thanks a lot,
Alex

Comments

msypes’s picture

I'm having the same problem. At first I thought it was because I was using Rules to set the taxonomy term on content save, and it was doing it after the save, but apparently that's not the case.
As stated above, whether I use a Rule to set the taxonomy term, set it by hand or use hook_alter_form to set the value, it's still not showing up in the title on initial save, only after editing.
Subscribing to this in the hopes that someone has an answer.
Michael

Michael

neuronomicon’s picture

I don't know if this will help, and it's kind of rough and ready, but I set auto nodetitle to evaluate php and used

<?php
print taxonomy_get_term($node->taxonomy[xxx])->name;
?>

where xxx is the vid which I found by peeking into the mysql database at the vocabulary table :-)

bserem’s picture

for some reason this produces no results on my site...

--
http://srm.gr - Drupal Implementor

neuronomicon’s picture

the example is a for a "flat" taxonomy where only one item can be selected... it works consistently across a number of my sites. If multiple selection is enabled, you are looking at parsing an array

wind_kind’s picture

I have a vocab (List a vehicle) and terms (car make) and then terms (models) as children of the "car make" term. How can I get only the car make and model into the URL? I don't know any PHP so I don't know how I would go about parsing an array as you mentioned.

Thanks for any help.

wind_kind’s picture

Don't worry I found an answer here, thanks.
http://drupal.org/node/137669#comment-4558634

Yuri’s picture

Works great, thanks.
You can also see the vid number in the url when opening the 'edit vocabulary' page.

pendashteh’s picture

thanks. it worked for me. one can use tokens like this:

$vocab_id = 1; // find out from here: /admin/content/taxonomy/
echo '[type]-' . taxonomy_get_term($node->taxonomy[$vocab_id])->name;

has somebody tried ever to update a node after creation using Rules to see if [nid], [term], etc. works fine?

papaoso84’s picture

Works great.... I o u a beer ;)