Line break in repeater text box

I have read some other answers about this but don’t understand how/where to implement the “/n” feature to create a line break for a lot of text in one of my database columns that flows through to a repeater.

(This is the one entry that seems to be closest to what I’m asking but I don’t understand how to make it work - https://www.wix.com/code/home/forum/community-discussion/rich-text-not-a-solution-for-line-breaks)

  1. If I enter the text into the database column with property of “text” then I can’t seem to create a line break in the text. It just flows through into my repeater page as one long paragraph but at least the font size, etc. is how i want it for each repeater.

  2. If I enter the text into the database column with the property of “rich text” then it flows through to my repeater not heeding the font, etc. that I set up in the repeater. So then I need to format every single row in my database for that column to make it look the right way, defeating the purpose of a repeater page in my site to begin with.

If you look at the link above you will see an answer incorporating “/n” but I can’t just input that in my database text box as it just goes through as /n. Is there a simple way to make a line break in text in database and have it flow through to repeater?

Please help.

you can’t directly.

BUT

There are 2 different ways of solving this, getting the line break into the DB or displaying them afterwards.
I think the first option is the most straightforward since you don’t need to code at all.


Getting the line-breaks into the DB

You can’t add them directly in the DB editor (afaict). But you can import them.
The most simple way to do this is to export the current data (it’s enough to have one single entry) see CMS (Formerly Content Manager): Exporting Content from Your Collection | Help Center | Wix.com

Open it with some spreadsheet application (or some writing app, but you must know what you are saving if you do that!). Add the line-breaks (some applications require to press shift-enter or ctrl-enterl to add the line break). In my case I used Libreoffice Calc and have to press F2 on a cell to paste the content with line breaks.

You can then import the DB and you should see your line breaks.


Coding time

This is a little more complicate and involves adding the line breaks in the DB as “\n” (which will get “recoded” into \n, escaping the original meaning of line break, you can use whatever you want actually, it will signal the place where a line break is to be expected).

Then it really depends where exactly you are writing the data, but the trick is replacing those string by line breaks.
For example, I have a repeater linked to the dataset which has some other functionality, so I manipulate the entries directly in this functions:

$w.onReady( function () {
$w(‘#repeater1’).onItemReady(($item, itemData, index) => {
itemData.txtWLinebreaks = itemData.txtWLinebreaks.replace(/\n/g, ‘\n’)

You need to replace:
#repeater1’ is just the id of the repeater section.
txtWLinebreaks is the name of the database column containing the values with the line breaks.

This might be tricky so stick with the previous solution.

This use to be so much easier and without the hassle.