3

I am writing a Drupal module that deals with the taxonomy terms, which are (as I understand) fields, taxonomy vocabulary , which are as I understand entities. My module should take over the taxonomy term field and vocabulary entity for mirror language display, meaning that once my user is in X language, he will see the X language value of the term/vocabulary name/description.

Looking at the i18n_taxonomy module code I can see that it implements many fields related functions (i18n_taxonomy_field_attach_view_alter(), i18n_taxonomy_field_formatter_view(), i18n_taxonomy_field_formatter_info(), etc). My questions are:

  • Once I need to to take over a display of a field, how can I do it?
  • What functions should my module implement for displaying the fields on menus, widgets, plain view, etc?
  • Same question, only for the vocabulary: is there any difference?
  • I have spent my time googling this subject, but I have not really found a good reference. Can anyone refer me to one?
1
  • Both terms and vocabularies are entities. "Taxonomy reference" is a field, which you can attach to other entities to assign terms to them.
    – Berdir
    Commented Mar 30, 2011 at 16:55

1 Answer 1

1

Fields are displayed through formatters (you can have multiple ones, and then you chose which one you want when adding the field to a content type, or any bundle of an entity). So, hook_field_formatter_info() and hook_field_formatter_view(). Open the core image module: modules/image/image.field.inc in your Drupal install, and use that as an example.

You can use hook_field_formatter_info_alter() to add formatters to existing field types (not declared by your mpdule).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.