Theming the field.tpl.php - accessing variables from a field collection I've got a field template which is rendering a field collection field using the standard field.tpl.php file:

  &lt;div class="field-items"&lt;?php print $content_attributes; ?&gt;&gt;
    &lt;?php foreach ($items as $delta =&gt; $item): ?&gt;
      &lt;div class="field-item &lt;?php print $delta % 2 ? 'odd' : 'even'; ?&gt;"&lt;?php print $item_attributes[$delta]; ?&gt;&gt;&lt;?php print render($item); ?&gt;&lt;/div&gt;
     &lt;?php endforeach; ?&gt;
  &lt;/div&gt;


I want to output the a CSS class inside the div in the loop with some text which comes from a colour field inside the $item variable.

EG. I would like to access the variable such as:
render($item['field_colour']);
in the loop, but this obviously doesn't work.

What's the best practice for doing this?
In standard field.tpl files you can access your field collection items using this code:

foreach ($items as $k) {
  foreach ($k['entity']['field_collection_item'] as $id =&gt; $field_collection) {
    $field_collection_item = field_collection_item_load($id);
    $field_wrapper = entity_metadata_wrapper('field_collection_item', $field_collection_item);
    $field_colour = $field_wrapper-&gt;field_colour-&gt;value();
  }
}


I don't know if it is a best practice to do that, but this is my way.