public function SlickGrouping::render_grouping_sets in Slick Views 7.3
Overrides StylePluginBase::renderGroupingSets().
Overrides views_plugin_style::render_grouping_sets
See also
https://www.drupal.org/node/2639300
File
- src/
Plugin/ views/ style/ SlickGrouping.php, line 170
Class
- SlickGrouping
- Slick style plugin with grouping support.
Namespace
Drupal\slick_views\Plugin\views\styleCode
public function render_grouping_sets($sets, $level = 0) {
$output = [];
$grouping = empty($this->options['grouping']) ? [] : array_filter($this->options['grouping']);
foreach ($sets as $set) {
$level = isset($set['level']) ? $set['level'] : 0;
$row = reset($set['rows']);
// Render as a grouping set.
if (is_array($row) && isset($row['group'])) {
$single_output = [
'#theme' => views_theme_functions('views_view_grouping', $this->view, $this->display),
'#view' => $this->view,
'#grouping' => $grouping[$level],
'#rows' => $set['rows'],
'#title' => $set['group'],
];
}
else {
$slick = $this
->render_row_group($set['rows'], $level);
// Views leaves the first grouping header to the style plugin.
if (!empty($grouping) && $level == 0) {
if (empty($this->options['grouping_optionset'])) {
$content[0] = $slick;
$content[0]['#prefix'] = '<h2 class="view-grouping-header">' . $set['group'] . '</h2>';
$single_output[0] = $content;
$single_output[0]['#prefix'] = '<div class="view-grouping">';
$single_output[0]['#suffix'] = '</div>';
}
else {
$single_output = $slick;
}
}
else {
$single_output = $slick;
}
}
$single_output['#grouping_level'] = $level;
$single_output['#title'] = $set['group'];
$output[] = $single_output;
}
return drupal_render_children($output);
}