Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FieldPluginBase.php

function FieldPluginBase::renderTrimText

Trims the field down to the specified length.

Parameters

array $alter: The alter array of options to use.

  • max_length: Maximum length of the string, the rest gets truncated.
  • word_boundary: Trim only on a word boundary.
  • ellipsis: Show an ellipsis (…) at the end of the trimmed string.
  • html: Make sure that the html is correct.

string $value: The string which should be trimmed.

Return value

string The rendered trimmed string.

1 call to FieldPluginBase::renderTrimText()
FieldPluginBase::renderText in core/modules/views/src/Plugin/views/field/FieldPluginBase.php
Performs an advanced text render for the item.

File

core/modules/views/src/Plugin/views/field/FieldPluginBase.php, line 1422

Class

FieldPluginBase
Base class for views fields.

Namespace

Drupal\views\Plugin\views\field

Code

protected function renderTrimText($alter, $value) {
    if (!empty($alter['strip_tags'])) {
        // NOTE: It's possible that some external fields might override the
        // element type.
        $this->definition['element type'] = 'span';
    }
    return static::trimText($alter, $value);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal