By Blakesterz on
I'm trying to figure out how to get the value "[name] => Washington" from below. field_an_events_state is a D7 field type "Term reference" that looks up the state from a taxonomy vocabulary. For a normal field, I can just do
print $content['field_event_country']['#items']['0']['value'];
But everything I've tried to get "[name] => Washington" from here fails me. This is in a node tpl file.
[field_an_events_state] => Array
(
[und] => Array
(
[0] => Array
(
[tid] => 52
[taxonomy_term] => stdClass Object
(
[tid] => 52
[vid] => 3
[name] => Washington
[description] => Washington
[format] => plain_text
[weight] => 0
[vocabulary_machine_name] => state_province
[rdf_mapping] => Array
Comments
How about print
How about
The last element (taxonomy_term) is an object not an array so you need to use
->name.Elements, Objects and Arrays
Thanks, that's what I needed, though it wouldn't work exactly like that, I needed to use #items rather than und. I don't know enough about these arrays yet to know what's what in here, but for the record, this works:
print $content['field_an_events_state']['#items']['0']['taxonomy_term']->name;