You are here

function node_field_node_content_add_node_fields in Node Field 7.2

Get render array of node fields.

Parameters

array $node_fields: Node fields to render.

Return value

array Drupal render array containing formatted node fields.

2 calls to node_field_node_content_add_node_fields()
node_field_handler_field_node_field::render in views/handlers/node_field_handler_field_node_field.inc
Render node fields.
node_field_node_view in ./node_field.module
Implements hook_node_view().

File

includes/node_field.api.inc, line 235
API and helpers functions for Node Field module.

Code

function node_field_node_content_add_node_fields(array $node_fields) {
  $content = [
    '#theme_wrappers' => [
      'node_field_fields',
    ],
  ];
  foreach ($node_fields as $node_field) {
    $node_field = node_field_node_field_formatter($node_field);
    $field = [
      '#theme' => 'node_field_field',
      '#node_field' => $node_field,
    ];

    // Add classes to field (if there are any).
    if (!empty($node_field['settings']['node_field_class'])) {

      // Class(es) of the field.
      $classes = explode(' ', $node_field['settings']['node_field_class']);
      $classes = array_filter($classes);
      $classes = array_map('drupal_html_class', $classes);
      $prefix = '<div class="' . implode(' ', $classes) . '">';
      $suffix = '</div>';
      $field['#prefix'] = $prefix;
      $field['#suffix'] = $suffix;
    }
    $content[] = $field;
  }
  return $content;
}