Skip to main content

Rendering a CCK field programmatically

Submitted by amitsedai on
Sometimes we need to render a field when we have a node object containing field values. field_view_value is a Drupal API that allows us to render any field. Example: Display the Invoice Description Field in a Node Object. The display would take care of any input filter that is applied in the field <?php $invoice_description = field_get_items('node', $node, 'field_invoice_description'); print render(field_view_value('node', $node, 'field_invoice_description',$invoice_description[0])); ?> The other way to display the label and data completely rendered by Drupal. <?php $invoice_description = field_get_items('node', $node, 'field_invoice_description'); print drupal_render($invoice_description); ?> -- Source: https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_value/7

Technologies