How do i get all the taxonomies of a node to render in Drupal7?

Sarah Berg

After following a tutorial for getting the taxonomy terms of a node, I found that I still didn’t have all the pieces of the puzzle. Doing a foreach over $tags = $node->field_tags; would just give a disappointing one result with those nodes had more than one taxonomy assigned to it. (The other 3 were being lost in the code abyss!)

This was solved by digging a little deeper into the object that was return:

<div class="tagsList views-field-field-tags">
	<? $tags = $node->field_tags['und']; ?>                            
	Tags: <? $count = 0; 
	foreach($tags as $tag){ 
	if($count > 0){echo ", ";}
	echo '<a href="'.taxonomy_term_path($tag['taxonomy_term']).'">'.$tag['taxonomy_term']->name.'</a>'; 
	$count++;
	} ?>
</div>

Turns out i had to go one layer deeper to loop the tags object as the language code is undefined. SO now my taxonomies are working great on the node.tpl.php for that feed.

Source

Last updated by on .

13 thoughts on "How do i get all the taxonomies of a node to render in Drupal7?"

  1. theneemies says:

    Did that code snippet work for you in D7? I had to replace taxonomy_term_path with taxonomy_term_uri. Cheers for the pointer though – very helpful!

  2. Okay that makes a lot more sense – didn’t mean to attack I just thought that your one rep maxes would be Those are reasonable 4-5 rep maxes – keep up the good work!

  3. usually posts some really interesting stuff like this. If youre new to this site

  4. we like to honor many other internet web sites around the internet, even though they arent linked to us, by linking to them. Under are some webpages worth checking out

  5. that could be the end of this post. Right here youll come across some internet sites that we assume you will enjoy, just click the hyperlinks over

  6. masturbating says:

    we like to honor numerous other world-wide-web sites around the net, even when they arent linked to us, by linking to them. Below are some webpages really worth checking out

  7. always a major fan of linking to bloggers that I appreciate but dont get a good deal of link appreciate from

  8. we like to honor lots of other internet web sites on the web, even though they arent linked to us, by linking to them. Below are some webpages worth checking out

  9. that would be the end of this article. Here youll find some web sites that we consider you will value, just click the links over

  10. that will be the finish of this write-up. Here youll discover some internet sites that we assume you will value, just click the links over

  11. always a major fan of linking to bloggers that I appreciate but dont get a good deal of link appreciate from

  12. we like to honor lots of other net websites around the net, even when they arent linked to us, by linking to them. Beneath are some webpages worth checking out

  13. below youll discover the link to some web sites that we feel you need to visit

What Are Your Thoughts?

Your email address will not be published. Required fields are marked *