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

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.