Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. $fc_fields = field_get_items('node', $node, 'field_image_teaser');
  2.  
  3. // Extract the field collection item ids
  4. $ids = array();
  5. foreach ($fc_fields as $fc_field) {
  6. $ids[] = $fc_field['value'];
  7. }
  8.  
  9. //Get the entities
  10. $collections = field_collection_item_load_multiple($ids);
  11.  
  12. //Loop over the array - if you have more than one entity
  13. for ($i = 1; $i <= sizeof($collections); $i++) {
  14. $collection = $collections [$i];
  15.  
  16. //Iterate over all member vars of the FieldCollectionItemEntity object
  17. foreach($collection as $key => $value) {
  18. //Look for fields - there are some other class vars, too.
  19. if (strpos ($key, 'field') !== false) {
  20. //Search for textfields
  21. if (isset($value['und']) && is_array($value ['und']) && isset($value['und'][0]['value'])) {
  22. print "Field ".$key." ".$value['und'][0]['value'];
  23. }
  24. }
  25. }
  26. }
  27.  
  28. //Iterate over all member vars of the FieldCollectionItemEntity object
  29. foreach($collection as $key => $value) {
  30. //Look for fields - there are some other class vars, too.
  31. if (strpos ($key, 'field') !== false) {
  32. //Search for textfields
  33. if (is_array($value) && isset($value['und']) && is_array($value ['und']) && (isset($value['und'][0]['value'])||isset($value['und'][0]['uri']))) {
  34. // print "Field ".$key." ".$value['und'][0]['value'];
  35. if(isset($value['und'][0]['value']))
  36. {
  37. $loadedValues[$i][$key] = $value['und'][0]['value'];
  38. }
  39. else if($value['und'][0]['uri'])
  40. {
  41. $loadedValues[$i][$key] = $value['und'][0]['uri'];
  42. }
  43. }
  44. }
  45. }
  46. $i++;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement