Drupal 7 : Load Field Collection

<?php // $content['field_foo']['#items'] : array of field collection id. if(isset($content['field_foo']['#items'])) : ?> <?php foreach($content['field_foo']['#items'] as $value): ?> <?php $my_field_collection = entity_load_single('field_collection_item', $value['value']); ?> <?php // Do something with $my_field_collection print $my_field_collection->item_id; ?> <?php endforeach; ?> <?php endif; ?>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.