I've created a cck field and called it authors so the machine name is field_authors. To print this field in a view template, i'm doing this - print $fields['field_authors_value']->content; In case is there 2 or 3 values it prints each value on separate line, and i want something like author1, author2, author3. (comma separated)

Tried to do this way in template.php:

function mytheme_content_view_multiple_field($items, $field, $values) {
  $output = '';
  switch($field['field_name']) {
    case 'field_authors_value':
      $output .= '<div class="field-item">'. implode(', ', $items) .'</div>';

      foreach ($items as $item) {
        if (!empty($item) || $item == '0') {
      $output .= '<div class="field-item">'. $item .'</div>';
  return $output;

but it has no effect. What im doing wrong?

1 Answer 1


Per the following on drupal.org: http://drupal.org/node/1018198#comment-3993646

You can do this by copying "views-view-field.tpl.php" into your theme's directory, under a name the view will recognize it selectively. Put the following code in it:

print preg_replace('/<\/div><div[^>]+>/i', ', ', $output);

In your case, I think it would be:


  • 1
    Thanks that worked. But it is possible to do that a more Drupl way? :) Sep 8, 2011 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.