DMXzone App Connect Support Product Page
Is there a feature like PHP's nl2br that I can use?
27 Apr 2018 13:43:18
27 Apr 2018 13:43:18 Bruce Wilkie posted:
I've got some text in a mediumtext field in my database and I'd like to display it on the page with the carriage returns/new lines intact.
At present when I show the text on the page it's all in a single line.
Is there a text formatting option that I can use similar to PHP's nl2br() that will show the new lines in the text and <BR> tags on the web page?
thanks in advance
28 Apr 2018 12:26:08
28 Apr 2018 12:26:08 Tom Dupre replied:
30 Apr 2018 08:41:30
30 Apr 2018 08:41:30 Bruce Wilkie replied:
Do I need to buy App Connect Medium Editor for this to work? If so, is there an alternative? Is there a simple command that works just like nl2br() ? Bruce
30 Apr 2018 09:01:38
30 Apr 2018 09:01:38 Bruce Wilkie replied:
I've found a script that's supposed to work:
30 Apr 2018 10:13:18
30 Apr 2018 10:13:18 Tom Dupre replied:
Did you try using the dmx-html attribute? You don't need any extra extensions for this.
30 Apr 2018 10:44:53
30 Apr 2018 10:44:53 Bruce Wilkie replied:
30 Apr 2018 12:53:02
30 Apr 2018 12:53:02 Tom Dupre replied:
Sorry - I was assuming there were <br> tags in the data.
Hopefully there is a simpler way to do this, but I think this works:
<p dmx-html="yourField.replace("\n", "<br>"
Again, it uses the dmx-html attribute, in addition to the 'replace' function. Using the interface, select:
Dynamic Attributes - Inner HTML - and use the value yourField.replace("\n", "<br>"
(via Data Formats)
01 May 2018 06:14:17
01 May 2018 06:14:17 Teodor Kuduschiev replied:
There are 3 ways of doing this with app connect: - Use replace(/\r\n|\r|\n/g, '<br>') with the dmx-html attribute (as the replace won't work without this attribute) - Put your text in a <pre> tag - Do this using CSS with the white-space: pre; property.
01 May 2018 14:08:39
01 May 2018 14:08:39 Bruce Wilkie replied:
Put it into a <pre> tag and styled it to match the rest of the text on the page.
Works a charm. Thanks
Reply to this topic Login to Reply