Thanks.. I will look into those options and see if I can get there..


On 28 May 2013 14:14, Lucas D Hedding <lucashedding@gmail.com> wrote:
If don't mind trying something new, I'd recommend using entity_metadata_wrapper from the entity API.

Here's a specific example using field collections and a more general example. I've found entity_metadata_wrapper to be much easier than dealing with $node->field_foo[LANGUAGE_NONE][0]['value'] all over the place. Place a dependency on entity in your .info file and have fun.



On Tue, May 28, 2013 at 7:59 AM, Nancy Wichmann <nan_wich@bellsouth.net> wrote:
Here's some code I use for dealing with collections. Perhaps it will help you to solve you problem.
  $collection = field_get_items($entity_type, $entity, 'field_consultant_cost_breakout');
  $count = count($collection);

  $total = 0;
  for ($i = 0; $i < $count; ++$i) {
    // Entity_load will return an array with the entity number as the key.
    $item = array_pop(entity_load('field_collection_item', array($entity->field_consultant_cost_breakout[LANGUAGE_NONE][$i]['value'])));
    $total += $item->field_total_cost[LANGUAGE_NONE][0]['value'];
  }


 
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.


From: Wipe_Out <wipe_out@users.sourceforge.net>
To: support@drupal.org
Sent: Tuesday, May 28, 2013 6:05 AM
Subject: [support] Accessing values in the $node variable..

Probably a simple syntax question but as a non-programmer I am battling with it..

I have created an "Invoice" content type that uses an entity reference to a "Patient" content type and within that there is a field collection for addresses.. I am trying to get the address in the first item in the field collection..

My guess is that I have to use something like "entity_load" which I will have to work out when I get there but at the moment I can't work out the syntax for accessing the field collection ID so I can try and load the data for the field collection..

--
[ Drupal support list | http://lists.drupal.org/ ]


--
[ Drupal support list | http://lists.drupal.org/ ]