Adding line breaks in language file text

4 posts by 2 authors in: Forums > CMS Builder
Last Post: November 20, 2018   (RSS)

By gkornbluth - November 17, 2018 - edited: November 18, 2018

Hi All,

I’m trying to add an additional “Tip” under the Add or Upload File(s) line of Upload fields.

I've found the entry for “Tip: hold <Ctrl> to select multiple files ==> Tip: hold <Ctrl> to select multiple files“ on line 222 of the lib/languages/en.php.

I’ve tried to insert a line break before the new text I'm adding by using a <br />, an \&lt; br \&gt;, an \r\n, and a \n, but discovered that the $tip variable on line 108 in lib/fieldtypes/upload.php uses htmlencode (in v 3.14) and so everything displays as those characters instead.

I can’t figure out how to insert a line break in the new “Tip” text without removing the htmlencode from line 108 (v 3.14), but I’m concerned that this approach creates a potential security breach, and possibly other issues (and besides, this code has been removed in V3.15).

Any ideas?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By daniel - November 19, 2018

Hi Jerry,

I would recommend against removing the htmlencode() function; it's not a particularly big security risk, but that's not a change likely to make it into the core code so you'd have to worry about redoing it any time you upgrade CMSB.

Instead, it might be more appropriate to add any additional text to the Description of the upload field. The description's output was accidentally dropped from the upload field in 3.14, but you can re-add it relatively easily by updating /cmsb/lib/menus/default/edit_functions.php (at line 886, just after the "Tip: hold..." text) to look like this:

...

  if (@$fieldSchema['maxUploads'] != 1) {
    echo '<div class="text-center">' . htmlencode( t("Tip: hold $key to select multiple files") ) . '</div>';
  }
?>
<br/>
<?php if ($description) { print "<p class=\"help-block\">$description</p>\n"; } ?>

...

This change will also be present in future releases of CMSB.

Let me know any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By daniel - November 20, 2018

Hi Jerry,

With that new code in place, you should be able to add text to the Description field when editing the upload field. This text won't display directly under the Tip text (it'll be left aligned and placed lower), but it should be possible to use HTML formatting to get your desired results. For example, the following should put two lines directly under the Tip:

<span style="display: block; text-align: center; margin-top: -22px;">Other text<br />3rd line</span>

Hope that helps!

Thanks,

Daniel
Technical Lead
interactivetools.com