It would be nice to have a comma separator between multiple values.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

langworthy’s picture

Status: Active » Needs review
FileSize
757 bytes
texas-bronius’s picture

Status: Needs review » Reviewed & tested by the community

+1
Works for me!

texas-bronius’s picture

Status: Reviewed & tested by the community » Needs review

Although that said, it wouldn't be bad to refactor the code a little like:

function theme_content_view_multiple_field($items, $field, $values) {
  $output = '';
  $cnt = count($items);
  $i = 0;
  foreach ($items as $item) {
    if (!empty($item) || $item == '0') {
      $separator = (($cnt - 1) > $i) ? ', ' : '';
      $output .= '<div class="field-item field-item-' . $i . '">' . $item . $separator . '</div>';
      $i++;
    }
  }
  return $output;
}

in order to write out the html out only 1 time and to reduce the call to count($items) from 1s per iteration to 1s ever.

I've slapped this back from @langworthy's rtbc to needs review, bc I am the only one who has tested my code above.

texas-bronius’s picture

Patch attached that does the above.

Rob T’s picture

I approached a similar issue using a patch from here for dealing with multiple value fields exported to XLS via Views Bonus Pack. https://drupal.org/node/758692

While it works for my particular need, this approach here as well as the approach provided here https://drupal.org/node/743200 are alternatives of interest.