token.export.tpl.php 998 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. */
  5. ?>
  6. /**
  7. * Implements hook_field_formatter_info().
  8. */
  9. function <?php echo $module; ?>_field_formatter_info() {
  10. return array(
  11. '<?php echo $module; ?>_<?php echo $item->name; ?>' => array(
  12. 'label' => t('<?php echo $item->label; ?>'),
  13. 'field types' => array('<?php echo implode('\', \'', drupal_explode_tags($item->field_types)); ?>'),
  14. ),
  15. );
  16. }
  17. /**
  18. * Implements hook_field_formatter_view().
  19. */
  20. function <?php echo $module; ?>_field_formatter_view($obj_type, $object, $field, $instance, $langcode, $items, $display) {
  21. $element = array();
  22. $pattern = "<?php echo addslashes($item->code); ?>";
  23. $info = token_get_info("{$field['type']}-field");
  24. $field_value = $info['field-value-type'];
  25. $output = '';
  26. foreach ($items as $item) {
  27. $output .= token_replace($pattern, array(
  28. $obj_type => $object,
  29. $field_value => $item,
  30. 'item' => $item,
  31. ));
  32. }
  33. $element[0] = array(
  34. '#markup' => $output,
  35. );
  36. return $element;
  37. }