1 node_example.module node_example_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display)

Implements hook_field_formatter_view().

@todo: We need to provide a formatter for the colors that a user is allowed to enter during node creation.

Related topics

File

modules/examples/node_example/node_example.module, line 199
Module file for Node Example module.

Code

function node_example_field_formatter_view($object_type, $object, $field, $instance, $langcode, $items, $display) {
  $element = array();
  switch ($display['type']) {
    case 'node_example_colors':
      foreach ($items as $delta => $item) {
        $element[$delta]['#type'] = 'markup';
        $color = $item['safe_value'];
        $element[$delta]['#markup'] = theme('example_node_color', array('color' => $color));
      }
      break;
  }

  return $element;
}