Field get items

Here's a useful one you may not know about: field_get_items().  Basically, if you're trying to get field values off an entity, it can be fiddly - dealing with language, indices, etc.  This function makes it much simpler. Just give it the Entity Type (e.g. 'node'), the entity itself and the field name (e.g. 'body'), and it will return the value that you are looking for.

See http://api.drupal.org/api/drupal/modules--field--field.module/function/field_get_items/7 for details.

 

Tags: 

Add new comment