function template_preprocess_uikit_view_grid in UIkit Components 8.2
Same name and namespace in other branches
- 8.3 uikit_views/includes/uikit_views.theme.inc \template_preprocess_uikit_view_grid()
- 8 uikit_views/includes/uikit_views.theme.inc \template_preprocess_uikit_view_grid()
- 7.3 uikit_views/templates/uikit_views.theme.inc \template_preprocess_uikit_view_grid()
- 7.2 uikit_views/templates/uikit_views.theme.inc \template_preprocess_uikit_view_grid()
Prepares variables for UIkit Grid templates.
Default template: uikit-view-grid.html.twig.
Parameters
array $variables: An associative array containing:
- view: A ViewExecutable object.
- rows: The raw row data.
1 string reference to 'template_preprocess_uikit_view_grid'
- UIkitViews::getThemeHooks in uikit_views/
src/ UIkitViews.php - Returns the theme hook definition information for UIkit Views.
File
- uikit_views/
includes/ uikit_views.theme.inc, line 75 - Preprocessors and helper functions to make theming easier.
Code
function template_preprocess_uikit_view_grid(array &$variables) {
$view = $variables['view'];
$options = $view->style_plugin->options;
$grid_classes = [
'uk-grid',
];
if ($options['grid_gutter'] != 'default') {
$grid_classes[] = $options['grid_gutter'];
}
foreach ([
'small',
'medium',
'large',
'xlarge',
] as $size) {
$grid_classes[] = $options["width_" . $size];
}
$variables['grid_classes'] = implode(' ', $grid_classes);
$variables['id'] = UIkitViews::getUniqueId($view);
$variables['options'] = $options;
$items = [];
// Iterate over each rendered views result row.
foreach ($variables['rows'] as $result_index => $item) {
$items[$result_index]['content'] = $item;
}
// Add items to the variables array.
$variables['items'] = $items;
}