How to print formatted contents of Computed Field and Full HTML Textarea in a custom template? I have used this code to print normal text fields in a print.tpl.php template file: 

&lt;?php if(isset($node-&gt;field_mytextfield['und'][0]['value'])) { 
          print $node-&gt;field_mytextfield['und'][0]['value'];
            }
     ?&gt;


But that same code will not work with Computed Fields I have set up in that same content type. The content type has a "Print" display type, and I have tried all of the Format options (Unsanitized, Plain Text, Filtered Markup, and Raw Value No Display Code) for the computed fields, to no avail. How can I print the formatted values of those computed fields, exactly as they are displayed by the actual fields themselves?

I also have a Textarea field that prints as a single line of unformatted text using the code above. How can I print the formatted value of that field when Full HTML is used to enter info into that field?

Thanks!
The Computed field defines its own formatting in the Display Code (PHP) box. If you have done your formatting there, when the page is processed, $vars will contain the output as:


Unsanitized: the output of Display Code (PHP) ($display_output) is unchanged.
Plain text: $display_output is filtered through the Plain Text filter.
Filtered markup: Non-permitted HTML tags are stripped from $display_output.
Raw Value: Display Code (PHP) is ignored and the value from Computed Code (PHP) is used ($entity_field[0]['value'] ).


This is fine for a rendered field using $vars. The Display output code is used when the node is preprocessed. If, however you wish to access the fields from the $node object, only the field value (Raw value) is presented. So you either have to duplicate the Display output code in your template, or you have to move the formatting into the Computed code box.

If you set your $entity_field[0]['value'] to the actual formatted string, then use the default $display_output = $entity_field_item['value']; in the Display output, you should be able to use the above code to display the field as is.

This is why it is much easier to use the processed fields. Instead of coding something like:

print $node-&gt;field_fieldname[LANGUAGE_NONE][0]['value'];


If $vars['field_fieldname'] has been set, the template file receives the result of extract($vars). Each array element becomes a variable in its own right and all you have to do in the template file is:

print $field_fieldname;


or 

print render($content['field_fieldname'];


if you have not separately included it in $vars in a preprocress. Much simpler when you understand how the data gets moved around.