/ Published in: PHP

Render the contents for a single node field.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// Full render, including value & labels $node = node_load($nid); $node = node_build_content($node, FALSE, FALSE); $rendered_field = drupal_render($node->content['field_name_to_render']); // Populate the node "view" values as if it was on a node template // Puts rendered values in $node->{field_name}['view'] $node = node_load($nid); $node->build_mode = 'full node'; $node = node_build_content($node); drupal_render($node->content); content_alter($node); // Render just a field $result = content_format({field_name}, $node->{field_name}[0], '{format_name}'); // {format_name} can be found from the output of: content_fields('{field_name}', '{node_type_name}');
Comments
