You are here

protected function SlickGrouping::render_row_group in Slick Views 7.3

Overrides StylePluginBase::renderRowGroup().

1 call to SlickGrouping::render_row_group()
SlickGrouping::render_grouping_sets in src/Plugin/views/style/SlickGrouping.php
Overrides StylePluginBase::renderGroupingSets().

File

src/Plugin/views/style/SlickGrouping.php, line 122

Class

SlickGrouping
Slick style plugin with grouping support.

Namespace

Drupal\slick_views\Plugin\views\style

Code

protected function render_row_group(array $rows = [], $level = 0) {
  $view = $this->view;
  $settings = $this->options;
  $view_name = $view->name;
  $view_mode = $view->current_display;
  $grouping = empty($settings['grouping']) ? [] : array_filter($settings['grouping']);
  $id = $grouping ? "{$view_name}-{$view_mode}-{$level}" : "{$view_name}-{$view_mode}";
  $id = Blazy::getHtmlId('slick-views-' . $id, $settings['id']);
  $settings = $this
    ->buildSettings();

  // Prepare needed settings to work with.
  $settings['id'] = $id;
  if (empty($grouping) && empty($settings['grouping_optionset'])) {
    $settings['nav'] = !$settings['vanilla'] && $settings['optionset_thumbnail'] && isset($view->result[1]);
  }
  $build = $this
    ->buildElements($settings, $rows);

  // Extracts Blazy formatter settings if available.
  if (empty($settings['vanilla']) && isset($build['items'][0])) {
    $this
      ->blazyManager()
      ->isBlazy($settings, $build['items'][0]);
  }

  // Supports Blazy multi-breakpoint images if using Blazy formatter.
  $settings['first_image'] = isset($rows[0]) ? $this
    ->getFirstImage($rows[0]) : [];
  $build['settings'] = $settings;
  $elements = $this
    ->manager()
    ->build($build);

  // Attach library if there is no results and ajax is active,
  // otherwise library will not be attached on ajax callback.
  // Note the empty space, a trick to solve: Undefined variable: empty...
  // No markup is output, yet the library is still attached on the page.
  // When this is reached, the $elements is an empty array.
  if (empty($this->view->result) && $this->view->use_ajax) {
    $elements['#markup'] = ' ';
    $elements['#attached'] = $this
      ->manager()
      ->attach($settings);
  }
  return $elements;
}