You are here

public function Field::renderItems in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/field/Field.php \Drupal\views\Plugin\views\field\Field::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/Field.php, line 670
Contains \Drupal\views\Plugin\views\field\Field.

Class

Field
A field that displays entity field data.

Namespace

Drupal\views\Plugin\views\field

Code

public function renderItems($items) {
  if (!empty($items)) {
    $items = $this
      ->prepareItemsByDelta($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 = array(
        '#theme' => 'item_list',
        '#items' => $items,
        '#title' => NULL,
        '#list_type' => $this->options['multi_type'],
      );
    }
    return $this->renderer
      ->render($build);
  }
}