Keyword

Extrafield Textarea: Line breaks in non-editor text area not working in frontend

  • SPOTTERON
  • SPOTTERON's Avatar Topic Author
  • Offline
  • Junior Member
More
4 years 1 week ago - 4 years 1 week ago #175498 by SPOTTERON
When configuring the extra field type textarea to be used without editor, the line breaks made in the backend > k2 > item are not taken over in the frontend.
Example:

Textarea box in backend:
This is an adress
with a city
and a post code.

Returns in frontend:
This is an address with a city and a post code.

Can linebreaks without adding HTML codes be used in text areas? The people creating the content of the site do not know HTML and it is right out of a strange world for them:)

Thanks and best regards,
Jonathan

Old member
Last edit: 4 years 1 week ago by SPOTTERON.

Please Log in or Create an account to join the conversation.

More
4 years 1 week ago - 4 years 1 day ago #175504 by JoomlaWorks
You can either modify the foreach loop and wherever you have a textarea type field apply the nl2br() function from PHP or call the field directly (using this guide getk2.org/documentation/tips-a-tricks/display-single-extra-fields-anywhere-in-your-k2-content) and applying (again) nl2br() on it.

E.g. using the 2nd option:
<?php echo nl2br($this->item->extraFields->EXTRAFIELD_ALIAS_HERE->value); ?>

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Last edit: 4 years 1 day ago by JoomlaWorks.

Please Log in or Create an account to join the conversation.

  • SPOTTERON
  • SPOTTERON's Avatar Topic Author
  • Offline
  • Junior Member
More
4 years 1 day ago #175676 by SPOTTERON
Thank you very much!
That solution works well, I have changes "name" to "value" since we want to display the extrafield's content, but the suggestion was very helpful!
(closed)
Jonathan

Old member

Please Log in or Create an account to join the conversation.

More
4 years 1 day ago #175682 by JoomlaWorks
That was a copy/paste mistake. Sorry for that, corrected now.

:)

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum