Rendering Drupal 7 fields... the right wayRendering Drupal 7 fields... the right way

// This is WRONG example.
$block['content'] = $node->field_name['und'][0]['safe_value'];

// This is the RIGHT example.
$output = field_view_field('node', $node, 'field_name');

// Better yet, there's another handy field API function, field_view_value()... Here's an example:
$node = node_load($nid);
$field = field_get_items('node', $node, 'field_name');
$output = field_view_value('node', $node, 'field_name', $field[$delta]);
// Where $delta is the field value you want. On a single value field this would be 0.

Tagged topics:
Website by Burtronix: Drupal Websites
Contact Burtronix for Drupal, Website Design and Custom PHP B2B Service Solutions