Properly get entity field values

If you're using $node->field_foo[LANGUAGE CODE] to get field values you should know about best practices in community developed for this.


You have to use field_get_items to handle this case:

field_get_items($entity_type, $entity, $field_name, $langcode = NULL);

For example:

$items = field_get_items('node', $node, 'field_foo');

The function will handle the language for you, If you need a specific language you should provide a language code as 4-th argument.

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************