Hi all

I've just setup my new drupal site and got the blog running. I have a question about the rendering of the categories for a blog post thought, it's rendered as a ul-list, is there a way to change this to a comma seperated list?

cheers!
/simpelipo

Comments

heytrish’s picture

I just tried it out, and it works. It lists all taxonomy related to the viewing node.
Insert/replace the following into your blog.tpl.php

<div class="taxonomy">
<?php
$count = 0;
$vocabularies = taxonomy_get_vocabularies();
  foreach($vocabularies as $vocabulary) {
    if ($vocabularies) {
      $terms = taxonomy_node_get_terms_by_vocabulary($node->nid, $vocabulary->vid);
      $termslist = '';
      if ($terms) {
	$nos = count($terms);
        foreach ($terms as $term) {
		$count += 1;
		if ($count == $nos) $comma = ', '; else $comma = '';					
		$termslist .= l($term->name, taxonomy_term_path($term)) . $comma;
        }
      print $termslist; 
      }
    }
  }
?></div>

works for 5x
RE: http://drupal.org/node/53089

simpelism’s picture

Hi!

I'm on Drupal 6.2 and at least for me your solution didn't work. Thanks to your code I managed to create my own solution thought, here it is:

$terms = $node->taxonomy;

if($terms) {
	$length = count($terms);
	$i = 1;
	
	print "Categories: ";
	
	foreach($terms as $t) {
		print "<a href='/taxonomy/term/".$t->tid."'>".$t->name."</a>";
		if($i != $length) {
			print ", ";
		} 
		$i++;
	}
	
	
}