Can anyone of you brainy folk suggest the best way of retrieving the taxonomy term on a node and both of it's parents then storing as variables on a php snippet? For example: Country->City->District output to $country, $city and $district?
Thanks in advance for all your answers!...
nb, this is what I get from print_r, [0] being the country, [1] being the area and [2] the district:
field_location_term] => Array
(
[und] => Array
(
[0] => Array
(
[tid] => 26
[taxonomy_term] => stdClass Object
(
[tid] => 26
[vid] => 5
[name] => B----a
[description] =>
[format] => filtered_html
[weight] => 3
[vocabulary_machine_name] => geographical_location
[metatags] => Array
(
)
)
)
[1] => Array
(
[tid] => 27
[taxonomy_term] => stdClass Object
(
[tid] => 27
[vid] => 5
[name] => B----o
[description] =>
[format] => filtered_html
[weight] => 0
[vocabulary_machine_name] => geographical_location
[metatags] => Array
(
)
)
)
[2] => Array
(
[tid] => 28
[taxonomy_term] => stdClass Object
(
[tid] => 28
[vid] => 5
[name] => M----w
[description] =>
[format] => filtered_html
[weight] => 0
[vocabulary_machine_name] => geographical_location
[metatags] => Array
(
)
)
)
)
I thought the best thing to do would be
$country = $node->field_location_term['und'][0]['taxonomy_term']['name'];
But I get no output.
$country = $node->field_location_term['und'][0]['taxonomy_term']->name;
- DOH!