2

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 -

field_call_to_action['und'][0]['value'] 
which is equal to 231. I still don't see the actual values of the fields in the field collection.

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

2 Answers 2

2

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"]) ...
0

Few of the tutorials that may be helpful for you:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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