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

Breadcrumb

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

function 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);
    }
}

API Navigation

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