0

I have a field in one of my content types called lab_test_id. When Editors add content of that type they enter all the ids of the lab tests associated with that node. I need to be able to take that id, call that lab test database, and display the lab test fields I get back.

Can I accomplish that by changing the display of the lab_test_id field via hook_field_display_alter or should I find another way to accomplish that?

  • "call that lab test database, and display the lab test fields I get back." - are "lab tests" drupal content, or is that completely separate custom database outside drupal? – tdd Aug 6 '15 at 5:48
  • It is a completely separate custom database – Eluchel Aug 6 '15 at 5:56
  • Drupal works easier if the content is located within its own database. If you would have 'lab tests' as a content type, it would as easy as to work with Entity reference and Display Suite :-) You 'could' duplicate the data to Drupal first with Feeds or something if that is an approach you would like. – Kevin Aug 6 '15 at 8:36
1

I think you can do this using hook_field_display_alter, however, I would personally prefer to create a custom formatter for the used field type. With the main advantage that you can save settings for the field formatter.

See the answers of How do I write an additional field formatter for an existing field for basic steps on how to create your own field formatter.

| improve this answer | |
  • Going to your link I found a nice little module called Custom Formatters which might do the trick too. It does the same thing just is set up so that you don't have to set up a custom module. – Eluchel Aug 6 '15 at 16:53
  • Interesting module, didn't know about that one yet :) – Watergate Aug 6 '15 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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