Get field_collection values in field template I have installed field_collection and have a collection called field_contact,
each entry of which has a field called field_contact_url

I'm trying to customise the display of that field by overriding the view template, using the file views-view-field--field-contact.tpl.php

The template is being used, if I put a simple print 'hello' I can see the hello come up, but I cannot figure out how to access the field_collection properties.
I've gone through every answer and example I can find on google, but all of them seem to rely on a variable that is not there.


$content is not present
$node is not present
$field is present, but $field-&gt;field-&gt;id is empty
$items is not present


I tried using this example, but the $rows is not showing up (perhaps because I put the functions in the wrong file... I put them both in the template.php file.

I have spent 6 hours trawling through Drupal docs, would really appreciate if someone could help me figure out what variables I need or where I need to put the template file so the right variables become available.
This is the solution I came up with. The first line is a bit of a hack and I think is not very robust.

Also, I think i'm not using the entity_metadata "way" of accessing the contact fields - but it works for now.

Would welcome suggested improvements.

$candidate_node = node_load($row-&gt;node_node_nid);
$survey_node = node_load($row-&gt;{$field-&gt;field_alias});

$candidate_wrapper = entity_metadata_wrapper('node', $candidate_node);
$survey_wrapper = entity_metadata_wrapper('node', $survey_node);

foreach ($candidate_wrapper-&gt;field_contact-&gt;value() as $contact) {
    if (array_key_exists('und', $contact-&gt;field_type)) {
            $key = $contact-&gt;field_type['und'][0]['value'];
            $value = $contact-&gt;field_contact_url['und'][0]['safe_value'];
            print sprintf($format[$key], $key, $value, ucfirst($key), $score);
    }
}