-
Notifications
You must be signed in to change notification settings - Fork 0
/
views_limit_grouping.module
52 lines (46 loc) · 1.49 KB
/
views_limit_grouping.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @file
* Contains views_limit_grouping.module..
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Template\Attribute;
/**
* Implements hook_help().
*/
function views_limit_grouping_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the views_limit_grouping module.
case 'help.page.views_limit_grouping':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Views display plugin that allows limit the number of rows under each grouping field in a view') . '</p>';
return $output;
default:
}
}
/**
* Prepares variables for views limitgrouping rows templates.
*
* Default template: views-view-limitgrouping.html.twig.
*
* @param array $variables
* An associative array containing:
* - view: The view object.
* - rows: An array of row items. Each row is an array of content.
*/
function template_preprocess_views_view_limitgrouping(&$variables) {
$view = $variables['view'];
$rows = $variables['rows'];
$style = $view->style_plugin;
$options = $style->options;
$variables['default_row_class'] = !empty($options['default_row_class']);
foreach ($rows as $id => $row) {
$variables['rows'][$id] = [];
$variables['rows'][$id]['content'] = $row;
$variables['rows'][$id]['attributes'] = new Attribute();
if ($row_class = $view->style_plugin->getRowClass($id)) {
$variables['rows'][$id]['attributes']->addClass($row_class);
}
}
}