hook_field_formatter_view

Public

Get raw version
php
  1. function nutoolbox_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  2. $elements = array();
  3. $settings = $display['settings'];
  4.  
  5. switch ($display['type']) {
  6. case 'text_gras':
  7. foreach ($items as $delta => $item) {
  8. $elements[$delta] = array(
  9. '#markup' => '<strong>' . $item['safe_value'] . '</strong>',
  10. );
  11. }
  12. break;
  13. case 'text_liste':
  14. $elementWrap[0] = ($settings['element_tag'] != '- None -') ? '<' . $settings['element_tag'] . '>' : '' ;
  15. $elementWrap[1] = ($settings['element_tag'] != '- None -') ? '</' . $settings['element_tag'] . '>' : '' ;
  16. $wrapper[0] = ($settings['wrapper_tag'] != '- None -') ? '<' . $settings['wrapper_tag'] . '>' : '' ;
  17. $wrapper[1] = ($settings['wrapper_tag'] != '- None -') ? '</' . $settings['wrapper_tag'] . '>' : '' ;
  18. $rows = '';
  19. foreach ($items as $delta => $item) {
  20. $rows .= $elementWrap[0] . $item['safe_value'] . $elementWrap[1];
  21. }
  22. $elements[0]['#markup'] = $wrapper[0] . $rows ; $wrapper[1];
  23. break;
  24. }
  25.  
  26. print_r($elements);
  27.  
  28. return $elements;
  29. }