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

Thanks For looking at this, Daniel, (but don't you ever go home?)

I found the code (actually on line 883 in V3.15)

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

and will add

<br/>
<?php if ($description) { print "<p class=\"help-block\">$description</p>\n"; } ?>

I'm still not really clear how I'd add a second or third line with a line break so that the final output is, for example:

Tip: hold $key to select multiple files
Some other text on new line
Some additional text on new line

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