line break format for textboxes <br/> vs <br>

11 posts by 4 authors in: Forums > CMS Builder
Last Post: March 11, 2019   (RSS)

By Deborah - March 5, 2019 - edited: April 12, 2019

Hi.

I'd like to know how I can replace the HTML line break code generated with each line break in a textbox field.

For example:

CMSB-generated XHTML tag format: <br/>
HTML5 desired tag format: <br>

Instead of using preg_replace to replace this in the HTML (which gets tricky with multiple line breaks), I'd prefer to edit the CMSB code so it generates the newer code by default.

I understand that an upgrade would impact such a change and keep good notes of any customization, so that's no problem. Just don't know where to make this change.

Thanks in advance.
~ Deborah

line break format for textboxes <br /> vs <br />

By daniel - March 5, 2019

Hi Deborah,

Fortunately, this is possible by customizing the TinyMCE configuration and adding the following option:

element_format : "html",

If you haven't already done so, you'll need to copy /lib/wysiwyg.php to create /lib/wysiwyg_custom.php, and the option will go in the configuration block following "tinyMCE.init({"

Let me know if you have any further questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

line break format for textboxes <br /> vs <br />

By Deborah - March 6, 2019

Daniel, thank you for the suggestion.

I gave it a try, but it did have a visible effect. The code written to the database (after re-saving) still recorded as <br/>. That's probably because the generated code for textboxes is written by CMSB, not TinyMCE. (I think.)

I've now discovered that editing the following in /lib/common.php accomplishes what I want.

ORGINAL CODE:
case 'textbox':
$fieldValue = $_REQUEST[$fieldPrefix.$fieldname];
if ($fieldSchema['autoFormat']) {
$fieldValue = preg_replace("/\r\n|\n/", "<br/>\n", $fieldValue); // add break tags
-----
CHANGED <br/> HERE:
$fieldValue = preg_replace("/\r\n|\n/", "<br>\n", $fieldValue); // add break tags

Thanks again for your help.

~ Deborah

line break format for textboxes <br /> vs <br />

By Dave - March 6, 2019

Hi Deborah, 

Thanks!  I've updated that in our code for the next release.

Dave Edis - Senior Developer
interactivetools.com

line break format for textboxes <br /> vs <br />

By Deborah - March 6, 2019

Dave, that will be great!

And if you feel it's time to shift to HTML5, it would be helpful to also have the Code Generator code updated...

- Line breaks from <br/> to <br> 
- Closing image tags from ' /> to '>' (no space or forward slash)
- Horizontal rule from <hr/> to <hr>
- Anything else I missed?

Not a big deal... I rarely use the line breaks or horizontal rule, but the image tags I always have to edit.

~ Deborah

line break format for textboxes <br /> vs <br />

By zaba - March 7, 2019

This is optional in html5 for self closing tags, such as

<br /> <img /> <hr />

it helps to retain them as it provides a visual clue of non-closing tags.

Why would you need to replace them, just curious?

line break format for textboxes <br /> vs <br />

By Dave - March 7, 2019

Hi All, 

We've updated that for the next beta release. 

As zaba says it's not technically required but we like to keep the software and generated code "looking modern".  

Now I just need to remember to stop adding it myself!

Dave Edis - Senior Developer
interactivetools.com

line break format for textboxes <br /> vs <br />

By zaba - March 7, 2019

Dave, do you have any code to stop me from placing my pen at exactly 90degrees in relation to my keyboard? 😀

line break format for textboxes <br /> vs <br />

By Dave - March 11, 2019

Zaba, We actually do have a plugin in development for that, but it only works if your pen is running the latest firmware. ;-)

Dave Edis - Senior Developer
interactivetools.com