phpdrupaldrupal-7drupal-computed-field

Trying to understand the Drupal 7 computed fields module


I just installed the computed fields module and I'm a little lost as to how to use it. I have 2 fields in my content type: field_shortdesc and field_audio_description.

If field_shortdesc is blank I need to display field_audio_description and vice-versa.

What code do I need to place into the computed code and display code areas? Seems like I can't get even the simplest code to work.

For example if I put $entity_field[0]['value'] = "test"; in the computed area and then put print $entity_field[0]['value']; in the display code area nothing gets printed out. Obviously I'm doing something completely wrong.


Solution

  • Note the help text in the Display Code section states:

    This code should assign a string to the $display_output variable, which will be printed when the field is displayed.

    Instead of print $entity_field[0]['value'] try $display_output = $entity_field[0]['value']