Drupal, Automatic Node Titles and Tokens

An annoying issue when using the Automatic Node Titles module in Drupal 6 is that when you create a node you have no access to certain tokens which require the node to be saved first. In my case, I was trying to include a taxonomy term in the node title.

The solution is to access the form data using the PHP $_POST variable. This variable contains all the form data.

$term = '[term]';

if (empty($term)) {
$tid = $_POST['taxonomy'][2];
$termobj = taxonomy_get_term($tid);
$term = $termobj->name;

return $term);

You must change the number in this line “$_POST[‘taxonomy’][2]” to your taxonomy number. Thanks to tanoshimi for this post.

Leave a Reply