function views_ui_truncate

views_ui_truncate($string, $length)

Truncate strings to a set length and provide a '...' if they truncated.

This is often used in the UI to ensure long strings fit.

File

core/modules/views_ui/views_ui.module, line 321
Provide structure for the administrative interface to Views.

Code

function views_ui_truncate($string, $length) {
  if (Unicode::strlen($string) > $length) {
    $string = Unicode::substr($string, 0, $length);
    $string .= '...';
  }

  return $string;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views_ui!views_ui.module/function/views_ui_truncate/8.1.x