Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $fc_fields = field_get_items('node', $node, 'field_image_teaser');
- // Extract the field collection item ids
- $ids = array();
- foreach ($fc_fields as $fc_field) {
- $ids[] = $fc_field['value'];
- }
- //Get the entities
- $collections = field_collection_item_load_multiple($ids);
- //Loop over the array - if you have more than one entity
- for ($i = 1; $i <= sizeof($collections); $i++) {
- $collection = $collections [$i];
- //Iterate over all member vars of the FieldCollectionItemEntity object
- foreach($collection as $key => $value) {
- //Look for fields - there are some other class vars, too.
- if (strpos ($key, 'field') !== false) {
- //Search for textfields
- if (isset($value['und']) && is_array($value ['und']) && isset($value['und'][0]['value'])) {
- print "Field ".$key." ".$value['und'][0]['value'];
- }
- }
- }
- }
- //Iterate over all member vars of the FieldCollectionItemEntity object
- foreach($collection as $key => $value) {
- //Look for fields - there are some other class vars, too.
- if (strpos ($key, 'field') !== false) {
- //Search for textfields
- if (is_array($value) && isset($value['und']) && is_array($value ['und']) && (isset($value['und'][0]['value'])||isset($value['und'][0]['uri']))) {
- // print "Field ".$key." ".$value['und'][0]['value'];
- if(isset($value['und'][0]['value']))
- {
- $loadedValues[$i][$key] = $value['und'][0]['value'];
- }
- else if($value['und'][0]['uri'])
- {
- $loadedValues[$i][$key] = $value['und'][0]['uri'];
- }
- }
- }
- }
- $i++;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement