I’m using Automatic Node titles to create node titles based on taxonomy terms. In my node I have 3 flat vocabulary:

Color, size, year.

One CCk field for the price.

And 1 hierarchical vocabulary(Makes and models)using a dropdown list.

I want the title to Show only terms from the hierarchical vocabulary(Makes and models)..Something like this:

 [Make term][ Model term ]  for [ price ] $.

This is easy to do with Drupal 7, using term patterns, but with Drupal 6, I guess the best option would be to use PHP. Which I have no clue about. I found this code here:

      <?php  $terms = array_values($node->taxonomy[1]);
       print taxonomy_get_term( $terms[0] )->name;
       print taxonomy_get_term( $terms[1] )->name;   

But It’s not working at all. Any idea?.

1 Answer 1


I suppose that one of the simplest things to check would be that you're calling the correct taxonomy id at this step: array_values($node->taxonomy[1]). If the taxonomy id of the make and model vocabulary you created isn't 1, this won't work as you expected.

The Devel module is very helpful for this. If you have it installed, you can open the node in question, click on the "Devel" tab and scroll down until you find taxonomy. It'll list the ids currently in use on the node.

Another way, if you don't have or want Devel, is to go to your taxonomy listing at 'admin/content/taxonomy'. When you click on "list terms" for your make and model vocabulary its id will be displayed in the URL.

That is the id you want to have in your first line: array_values($node->taxonomy[1])


As per your comment below, I would suggest using something like this:

$terms = taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid');

Where $node is the node object, $vid is the id of the vocabulary you want to limit the term search to.

Then you can loop through the terms using:

foreach($terms as $term) {
  print $term. " ";


Use the standard PHP function implode to put in your spaces:

implode(" ", $terms);

The added space will put spaces between the terms in the array. This is, of course, assuming the terms will be returned in an order that makes sense for what you're doing.

  • Thank you.. In my test site, I’m using the correct taxonomy Id:(3) But I’m still getting this error: warning: array_values() expects parameter 1 to be array, null given in /home/test/public_html/test/sites/all/modules/auto_nodetitle/auto_nodetitle.module(220) : eval()'d code on line 3. The error happend every time I Update the automatic title node. However, when I created the node for the first time, there is no error. Titles looks like this: Term1term2. Without space between terms.
    – Nizarnav
    Mar 18, 2012 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.