Reputation: 4459
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.
Upvotes: 0
Views: 4057
Reputation: 411
If you are talking about displaying the values in a view that uses fields, rather than viewing the node, there's an easier way to do this through the view settings, without adding another field.
If you only want to show one default value, even if both are present:
If you want to show both values if both are present, and you are using a table:
If not using a table, but want to show both values:
Upvotes: 0
Reputation: 8686
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']
Upvotes: 1
Reputation: 1
I dont think computed fields module is not the right solutin for your requirement.
In my opinion using Ajax state system is the best choice.
Upvotes: 0