I have added a field to the basic page content type (a field collection field, to be exact). I want to be able to pull out the content of each field and display it in different format. How can I do this? Which variable contains this data? I am using an override of page.tpl.php.

EDIT: I did try dpm($node) and I see the field collection field. However this is the structure I see -

which is equal to 231. I still don't see the actual values of the fields in the field collection.

  • 3
    entity_load('field_collection_item', array($node->field_collection_name['und']['0']['value'])); – harsh_behl_0007 Jan 14 '15 at 4:29

You may use entity_load. I have a project in which I use Field Collections as you, and this is a fragment of code in my module. I hope it helps you. The key is the use of entity_load.

    foreach($node->field_imagenes["und"] as $value){
                $a = entity_load('field_collection_item',     array($value["value"]));
                $prefered = false;
                if(isset($a[$value["value"]]->field_prefered_image["und"][0]["value"]) ...
| improve this answer | |

Few of the tutorials that may be helpful for you:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.