Custom field formatters allow for more control over how field values are displayed. They are defined through hook implementations like hook_field_formatter_info() and a theme function. The theme function receives the field element and is responsible for outputting the formatted field value. Sanitization of user input should be done to prevent XSS attacks. Drupal 7 uses hook_field_formatter_view() instead of a theme function.
2. Jody Hamilton
Owner, Lead Developer at Zivtech
Drupal architect, developer, themer, site-
builder, project manager, teacher and
student
Jody Lynn on drupal.org
12. hook_鍖eld_formatter_info
Provide meta information about your new
formatter: name, description, 鍖eld types
Return an array of formatter(s) keyed by
machine names.
13. hook_theme
Describe your new theme function (or
template) to Drupal
You must clear the theme registry when
adding/changing a hook_theme
implementation
14. Formatter Theme
Function
$element is the parameter
$element[#item] contains the meat
dpm to see what youre working with
15. Sanitize your Output
The responsibility for sanitizing user-
generated data falls on the themers and
developers who output it with code.
When in doubt: check_plain or
check_markup
16. Field Formatters in D7
hook_鍖eld_formatter_info includes settings
hook_鍖eld_formatter_info_alter !
hook_鍖eld_formatter_view (no theme
function)