function template_preprocess_views_bootstrap_panel in Views Bootstrap 8.3
Prepares variables for views panel templates.
Default template: views-bootstrap-panel.html.twig.
Parameters
array $vars: An associative array containing:
- view: A ViewExecutable object.
- rows: The raw row data.
1 string reference to 'template_preprocess_views_bootstrap_panel'
- ViewsBootstrap::getThemeHooks in src/
ViewsBootstrap.php - Returns the theme hook definition information.
File
- ./
views_bootstrap.theme.inc, line 269 - Preprocessors and helper functions to make theming easier.
Code
function template_preprocess_views_bootstrap_panel(array &$vars) {
$view = $vars['view'];
$vars['id'] = ViewsBootstrap::getUniqueId($view);
$group_title_field = isset($view->style_plugin->options['grouping'][0]) ? $view->style_plugin->options['grouping'][0]['field'] : "";
$panel_title_field = $view->style_plugin->options['panel_title_field'];
$panel_label_field = $view->style_plugin->options['panel_label_field'] ?? '';
$panel_footer_field = $view->style_plugin->options['panel_footer_field'];
$vars['attributes']['class'][] = 'panel-group';
$vars['panel_class'] = $view->style_plugin->options['contextual_class'];
foreach ($vars['rows'] as $id => $row) {
$vars['group_title'] = $group_title_field ? $view->style_plugin
->getField($id, $group_title_field) : "";
$vars['rows'][$id] = [];
$vars['rows'][$id]['content'] = $row;
$vars['rows'][$id]['title'] = $view->style_plugin
->getField($id, $panel_title_field);
$vars['rows'][$id]['label'] = $panel_label_field ? $view->style_plugin
->getField($id, $panel_label_field) : '';
$vars['rows'][$id]['footer'] = $view->style_plugin
->getField($id, $panel_footer_field);
}
// @TODO: Make sure that $vars['rows'] is rendered array.
// @SEE: Have a look template_preprocess_views_view_unformatted()
// and views-view-unformatted.html.twig
}