My field collection has 2 items: heading and body. I have to render them separately in the content type template because I am modifying one of the fields slightly in the display. Preview does not show the separate fields, normal display works fine. Here is a portion of my template code below.

$wrapper = entity_metadata_wrapper('node', $node);
$formtype = field_get_items('node', $node, 'field_anchor_section');

if($formtype!=null){
foreach($formtype as $itemid) {
$item = field_collection_field_get_entity($itemid);
if(isset($item->field_section_heading['und'][0]['safe_value']) && isset($item->field_section_body['und'][0]['safe_value'])){

$heading=$item->field_section_heading['und'][0]['safe_value'];
$body=$item->field_section_body['und'][0]['safe_value'];

print "

" .$heading. "

";
print $body;
}

}
}

Comments

izus’s picture

Assigned: mrprasa » Unassigned
Status: Active » Closed (duplicate)

hi,
i think this is a duplicate of https://www.drupal.org/node/1447338