Hi everyone!

I was looking for the snippet to display node terms from certain vocabulary and found this one:

<?php foreach ($node->taxonomy as $item) {
                        if ( $item->vid == 24 ) {
                            print '<li>'. $item->name .'</li>';
                            }
                        }
?>

Where vid is vocabulary id.

What I want to do is to create table cell and add vocabulary name. For example, if vid is 27 print <td>... vocabulary name... <ul><li>terms

I'm not much of a coder and I'd really appreciate any help. Thanks.

Comments

Equ’s picture

Anyone? :-(

WorldFallz’s picture

I have no clue what you're asking-- can you maybe create a little text sample of what you're trying to create?

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

Equ’s picture

Here is what I was looking for:

<?php
  $my_terms_output = ''; 
  foreach ($node->taxonomy as $item) {
     if ( $item->vid == 24 ) {
       $my_terms_output .= '<li>'. $item->name .'</li>';
     }
   }
$my_terms_output = $my_terms_output ? '<h2>Vocabulary name</h2><ul>'. $my_terms_output. '</ul>' : ''; 
print $my_terms_output;
?>
Jboo’s picture

Can anyone tell me how to use this but for the output to display as links rather than just text?

My new EasySnoozing, Nursing and BusinessEgghead websites on D7!