function views_ui_truncate

Same name in other branches
  1. 9 core/modules/views_ui/views_ui.module \views_ui_truncate()
  2. 10 core/modules/views_ui/views_ui.module \views_ui_truncate()

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

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

10 calls to views_ui_truncate()
Block::optionsSummary in core/modules/views/src/Plugin/views/display/Block.php
Provide the summary for page options in the views UI.
DisplayExtenderTest::optionsSummary in core/modules/views/tests/modules/views_test_data/src/Plugin/views/display_extender/DisplayExtenderTest.php
Provide the default summary for options in the views UI.
DisplayPluginBase::optionsSummary in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Provides the default summary for options in the views UI.
DisplayTest::optionsSummary in core/modules/views/tests/modules/views_test_data/src/Plugin/views/display/DisplayTest.php
Provides the default summary for options in the views UI.
DisplayTest::testDisplayTitleInButtonsXss in core/modules/views_ui/tests/src/Functional/DisplayTest.php
Ensures that no XSS is possible for buttons.

... See full list

File

core/modules/views_ui/views_ui.module, line 341

Code

function views_ui_truncate($string, $length) {
    if (mb_strlen($string) > $length) {
        $string = mb_substr($string, 0, $length);
        $string .= '...';
    }
    return $string;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.