Stephen Tweeddale

Rendering Drupal 7 fields (the right way)

A very useful article pointing out how to render fields properly in Drupal 7:

The short answer: Use field_view_field()!

Drupal 7 brought us Entities, and with them the powerful Field API for 'storing, loading, editing, and rendering field data.' attached to them. If you're managing everything through 'manage fields' and 'manage display' tabs of your content type, then every part of that process is rather wonderfully taken care of for you.

We often, however, come across the need to render a field outside the context of it's entity. A common example might include rendering a node's author in a sidebar block. Sure, modules like Panels and CCK Blocks will do this for you, but doing it manually is actually not that hard.

If you are a Drupal developer, read it all!