phpdrupal-7drupal-taxonomy

Comma separated taxonomy terms in Drupal


I'd like to separate my taxonomy terms with commas, and also not have a comma behind the last listed term.

I've seen there are some modules out there that might be a help, but I'd rather use a preprocess function, since I don't believe an extra module would be necessary for such a rather simple task.

I just can't figure out the right function and the php to it.

Could someone please help me with this?


Solution

  • Instead of using a preprocess function, you can overwrite theme_field() function for the tags field in the template.php file of the theme that you are using. In this function, you will render tags in comma-separated format. The advantage of this approach is that it's a more general solution and will work irrespective of the view mode of the taxonomy terms, i.e. whether they are rendered as links or just plain text.

    Since the solution requires a few steps, I have written a blog post on it. Here is the link: http://redcrackle.com/blog/how-show-comma-separated-taxonomy-terms-drupal.