I'm trying to display multiple taxonomy terms for one node in contemplate.

I can display one with this:

<?php print $node->field_bizcat[$node->language][0]['taxonomy_term']->name ?>

But to display several I need to do this, and it leaves blank spaces:

<?php print $node->field_bizcat[$node->language][0]['taxonomy_term']->name ?>
<?php print $node->field_bizcat[$node->language][1]['taxonomy_term']->name ?>
<?php print $node->field_bizcat[$node->language][2]['taxonomy_term']->name ?>
<?php print $node->field_bizcat[$node->language][3]['taxonomy_term']->name ?>

I'm pretty sure that in previous version Drupal and ConTemplate I was able to do this, but I can't see how.

I checked several places for reference, and all point to D6 and D5 versions. I've tried, but they don't work for me.


zigazou’s picture

Hi !

Do you mean that it leaves blank spaces where there should be term names ou that it leaves blank spaces when there’s no term name to display ?

In the latter case you should do something like this (not tested) :

foreach($node->field_bizcat[$node->language] as $field_bizcat) {
  print $field_bizcat['taxonomy_term']->name
coloryan’s picture

That's exactly what it's doing.

Am I wrong in thinking that it should display the full list through an array, or must each term be added individually like in my second example?

I ran your snippet, verbatim, and the template barfed on me.

Parse error: syntax error, unexpected '}' in /home/XXX/public_html/MYSITE.com/sites/all/modules/contemplate/contemplate.module(833) : eval()'d code on line 11

Thanks for the input, I really appreciate it.