How do I access field variables directly in Drupal 7 without having to drill down into a node array? I have a view reference field and have some php code in the view where it grabs the taxonomy ID of the page its currently on. Currently I am grabbing the TID via 

menu_get_object()-&gt;field_device_type_vocabulary[und][0][tid];


I know you can access the fields directly without having to do that, but forgot how that was done.
There are two main methods:


Procedural, using field_get_items(), e.g.

$node = menu_get_object();
if ($items = field_get_items('node', $node, 'field_device_type_vocabulary')) {
  $tid = $items[0]['tid'];
}

Objected oriented, using an EntityMetadataWrapper, e.g.

$node = menu_get_object();
$wrapper = entity_metadata_wrapper('node', $node);
$tid = $wrapper-&gt;field_device_type_vocabulary[0]-&gt;tid-&gt;value();