function node_example_field_formatter_view in Examples for Developers 7
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
- node_example/
node_example.module, line 229 - 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;
}