Search code examples
drupaldrupal-6drupal-views

Theming Drupal grouped multiple fields


I have a content type that has 4 images to it.

In my View they are grouped (Group Multiple Values).

I want to put each image in a seperate li, such as:

<ul class="list">                                    
<li><img src="/images/image1.jpg"/></li>
<li><img src="/images/image2.jpg"/></li>
<li><img src="/images/image3.jpg"/></li>
<li><img src="/images/image4.jpg"/></li>
</ul>

How do I achieve this? I assume I need to theme the field template file with a foreach loop, but I can't quite figure out what I'm supposed to be doing.

Thanks :)


Solution

  • Guys thanks for all your help, you pushed me in the right direction.

    I got round this by overriding a function called theme_content_view_multiple_field in my template.php

    function MYTHEME_content_view_multiple_field($items, $field, $values) {
      $output = '';
      $i = 0;
      foreach ($items as $item) {
        if (!empty($item) || $item == '0') {
          $output .= '<li class="test field-item field-item-'. $i .'">'. $item .'</li>';
          $i++;
        }
      }
      return $output;
    }
    

    Eventually I will edit it so that it only affects this particular field (such as http://drupal.org/node/556232)

    Cheers :)