You are here

readme.txt in Empty fields 8

Same filename and directory in other branches
  1. 7.2 readme.txt
  2. 7 readme.txt

Contains the CurrentTimeEmptyFieldText plugin for EmptyFieldHandler.

File

readme.txt
View source
  1. Empty fields module - http://drupal.org/project/empty_fields
  2. ============================================================
  3. DESCRIPTION
  4. ------------
  5. This module provides a way to show fields that are empty by new display
  6. formatter settings. These can be either custom text defined by the field
  7. administrator or the return value of a defined callback.
  8. REQUIREMENTS
  9. ------------
  10. Drupal 7.x
  11. Field formatter settings - http://drupal.org/project/field_formatter_settings
  12. INSTALLATION
  13. ------------
  14. 1. Place the Empty Fields modules into your modules directory.
  15. This is normally the "sites/all/modules" directory.
  16. Also download and place the Field formatter settings module here too.
  17. http://drupal.org/project/field_formatter_settings
  18. 2. Go to admin/build/modules. Enable the modules.
  19. The Empty Fields modules is found in the Fields section.
  20. Read more about installing modules at http://drupal.org/node/70151
  21. API
  22. ---
  23. For specific use-cases, you can define a custom callback to generate dynamic
  24. content.
  25. Firstly, implement hook_empty_fields(). This returns an array indexed by the
  26. class name that implements the handler.
  27. This differs from version 1.x that used hook_empty_field_callbacks().
  28. /**
  29. * Implements hook_empty_fields().
  30. */
  31. function HOOK_empty_fields() {
  32. $items = array(
  33. 'CurrentTimeEmptyFieldText' => array(
  34. 'title' => t('Display current time if empty'),
  35. ),
  36. );
  37. return $items;
  38. }
  39. ?>
  40. Create a new concrete class that extends the abstract class EmptyFieldHandler.
  41. /**
  42. * @file
  43. * Contains the CurrentTimeEmptyFieldText plugin for EmptyFieldHandler.
  44. */
  45. /**
  46. * Defines CurrentTimeEmptyFieldText class.
  47. */
  48. class CurrentTimeEmptyFieldText extends EmptyFieldHandler {
  49. /**
  50. * Implementation of EmptyFieldText::react().
  51. */
  52. public function react($context) {
  53. return format_date(time());
  54. }
  55. /**
  56. * Implementation of EmptyFieldText:summaryText().
  57. */
  58. public function summaryText() {
  59. return t('Empty Text: current time');
  60. }
  61. }
  62. ?>
  63. Register this class in your modules info file
  64. files[] = plugins/empty_fields_handler_current_time.inc
  65. The context has the entity_type, entity, view_mode as well as the empty field
  66. details, field and instance.
  67. If the callback is empty or a zero-length string, the empty field will not be
  68. rendered.
  69. ACKNOWLEDGEMENTS
  70. ----------------
  71. Core implementation was based of Field Delimiter module by Andrew Macpherson,
  72. (andrewmacpherson) and builds on the base concept started by Everett Zufelt in
  73. a support request at http://drupal.org/node/1283974#comment-5385242.
  74. It is made possible with Dave Reids Field formatter settings module that plugs
  75. a couple of the holes found in the core Drupal Field API.
  76. AUTHORS
  77. -------
  78. Alan D. - http://drupal.org/user/198838
  79. rypit - http://drupal.org/user/868380
  80. REFERENCES
  81. ----------
  82. Andrew Macpherson - http://drupal.org/user/265648
  83. Everett Zufelt - http://drupal.org/user/406552
  84. Dave Reid - http://drupal.org/user/53892
  85. Field Delimiter - http://drupal.org/project/field_delimiter
  86. Field formatter settings - http://drupal.org/project/field_formatter_settings