solved Newlines in database converted to HTML break for presentation

TiG
TiG
@tig
6 years ago
184 posts
I was reading with great interest a discussion close to this topic but it ended without a solution.

https://www.jamroom.net/the-jamroom-network/forum/jamroom-developers/38900/tinymce-inserting-line-breaks-into-some-list-items

One intriguing comment by Michael at the end was:

Quote:
TinyMCE will kindly reformat that so that its more readable
<h1>some big text</h1>
<p>then some small text</p>
and jamroom will go "Oh, you want an extra line in there and add a BR".

My question is which function of jamroom replaces the newline with a break? That is, when a comment is retrieved from the db with a newline, who is inserting the break before it is displayed?

Thanks,
TiG


--
TiG

updated by @tig: 10/18/18 05:44:57PM
michael
@michael
6 years ago
7,692 posts
First was comments in a textarea...(da da da insert music here). Then came TinyMCE....

So jamroom was setup to store the comments as they were formatted coming from the textarea, then in order to turn that into HTML that looks the same as it was formatted in the textarea nl2br() is added to the output.

So put a texteditor in place of a textarea and you end up needing to know which was used ( not which is active NOW ) to enter the text.

The answer to your question is:
which: nl2br()
who: jamroom

--edit--
The solution if its causing a problem for you is to exclude NL2BR from the string formatters.

eg: for blog's item_detail.tpl the blog text will be output like this:
{$item.blog_text|jrCore_format_string:$item.profile_quota_id}
The solution is to add 'nl2br' to the EXCLUDE list
{$item.blog_text|jrCore_format_string:$item.profile_quota_id:null:nl2br}

Then the BR won't be output.
updated by @michael: 07/19/18 11:09:43PM
TiG
TiG
@tig
6 years ago
184 posts
Thanks. I had looked for this function before and could not find any meaningful reference to
<br>
in the code. No wonder I did not discover the culprit. :)


--
TiG

updated by @tig: 07/20/18 08:32:42AM

Tags