Theresa Arzadon-Labajo

Theming grouped multiple values in Views

Posted by Theresa Arzadon-Labajo (tarzadon) on Dec 15 2010
Tech Stuff >> Drupal
I have a View with a field called Content: Author and checked off "".  The multiple values print on multiple lines in divs:
but I wanted them to print out on a single line separated by commas:

However, when looking at the $row array in the theme templates, those field_author_value fields don't show up at all.  This post talks about it:

The way to theme it is to create a function called mytheme_content_view_multiple_field($items, $field, $values) in template.php and it is described here and here.

I followed this example:

I like it. One modification would be to call out the field you want to alter, so all other fields get rendered the stock way.

function mytheme_content_view_multiple_field($items, $field, $values) {
if ($field['field_name'] == 'field_myfield' ) {
$output = '';
// Separate item values with my favorite separator.
$separator = ', ';
$array = array();
    foreach (
$items as $item) {
      if (!empty(
$item) || $item == '0') {
$array[] = $item;
'<span class="field-item">'. implode($separator, $array) .'</span>';
  else {
//else use the default function loacated at the bottom of cck/includes/views/
return theme_content_view_multiple_field($items, $field, $values);


Last changed: Feb 27 2020 at 4:12 PM