function EntityField::renderItems

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::renderItems()
  2. 8.9.x core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::renderItems()
  3. 10 core/modules/views/src/Plugin/views/field/EntityField.php \Drupal\views\Plugin\views\field\EntityField::renderItems()

Render all items in this field together.

When using advanced render, each possible item in the list is rendered individually. Then the items are all pasted together.

Overrides MultiItemsFieldHandlerInterface::renderItems

File

core/modules/views/src/Plugin/views/field/EntityField.php, line 732

Class

EntityField
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

public function renderItems($items) {
    if (!empty($items)) {
        if ($this->options['multi_type'] == 'separator' || !$this->options['group_rows']) {
            $separator = $this->options['multi_type'] == 'separator' ? Xss::filterAdmin($this->options['separator']) : '';
            $build = [
                '#type' => 'inline_template',
                '#template' => '{{ items | safe_join(separator) }}',
                '#context' => [
                    'separator' => $separator,
                    'items' => $items,
                ],
            ];
        }
        else {
            $build = [
                '#theme' => 'item_list',
                '#items' => $items,
                '#title' => NULL,
                '#list_type' => $this->options['multi_type'],
            ];
        }
        return $this->renderer
            ->render($build);
    }
}

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