function template_preprocess_filebrowser_container in Filebrowser 8.2
Same name and namespace in other branches
- 3.x filebrowser.theme.inc \template_preprocess_filebrowser_container()
Prepares variables for filebrowser form container template that shows the items in a grid view.
The id of the container is defined in service Common::ACTION_FORM_GRID_ID
Default template: filebrowser--container.html.twig.
Parameters
array $variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #id, #attributes, #children.
File
- ./
filebrowser.theme.inc, line 23 - Template preprocess functions for filebrowser
Code
function template_preprocess_filebrowser_container(&$variables) {
//debug(array_keys($variables));
//print('<pre>' . print_r(($variables)) . '</pre>');
$items = [];
$variables['has_parent'] = FALSE;
$element = $variables['element'];
// Ensure #attributes is set.
$element += [
'#attributes' => [],
];
// Special handling for form elements.
if (isset($element['#array_parents'])) {
// Assign an html ID.
if (!isset($element['#attributes']['id'])) {
$element['#attributes']['id'] = $element['#id'];
}
$variables['has_parent'] = TRUE;
}
$variables['children'] = $element['#children'];
$variables['attributes'] = $element['#attributes'];
//debug(count($variables['element']['#render_children']));
foreach ($variables['children'] as $item) {
$items[] = $item;
}
$variables['items'] = $items;
}