4

I'm using Drupal 7. I'm printing out a custom plain text textarea field in the node template using the following code:

print ($taxonomy_term->field_address['und'][0]['value']);

However, when I print it out I lose all the line breaks. Is there a way I can keep the line breaks in when I print out the field value?

I have already changed the plain text format to add "limit allowed HTML tags" rule for <a> <br> <p>, and removed the "display any HTML as plain text" rule.

Many thanks,

Ben

4

I worked it out. I just needed to use the following code:

print nl2br($taxonomy_term->field_address['und'][0]['value']);

This uses the print nl2br function to convert line breaks to <br> tags.

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.