Community

Views field theming help needed - node references as comma-separated list?

I'm attempting to create a tabled view in which a noderef field is expressed as a comma-separated list. For instance, if calling field_storyreference, Views wants to display it like this:

Story 1
Story 2
Story 3

If the field is grouped. I want it to display like this:

Story 1, Story 2, Story 3

So I'm writing a specific view field template for this purpose, but the node reference field data doesn't seem to be in $row so I'm not entirely sure how to get the data so I can implode it.

Comments

Node references as comma-separated list

I wrote a small module for this task. The module adds a formatters for the display fields and views.
Maybe it will help you.
You can download it here. The discussion pages of the module (in Russian) here and here.

WBR, Dmitrii

Great

Worked Great. Thanks!

The module does not work. Is

The module does not work.
Is this the correct version?
http://www.varvashenia.ru/images/cms/drupal/cck_comma_v0.2.zip
Thanks

JV

lates version of the module:

lates version of the module: http://www.varvashenia.ru/images/cms/drupal/cck_comma_v0.4.zip
for D6 only

WBR, Dmitrii

Use Theme developer module

Use Theme developer module from here http://drupal.org/themedeveloper to know which function to override for getting the field data.
I have tried it on my local site and it is working.

Here is the code (add it in the template.php)

function [THEME_NAME]_content_view_multiple_field($items, $field, $values) {
  $output = '';
  $a1 = "";
  foreach ($items as $item) {
    if ($field['field_name'] == 'field_test_ref')  /* replace field_test_ref with your field name */
  {
      $a1[]= $item;
      $a = implode(",", $a1);
    }
  }
  $output .= '<div class="test'.'">'. $a . '</div>';
  return $output;
}
nobody click here