function template_preprocess_field_collection_item in Field collection 8.3
Same name and namespace in other branches
- 8 field_collection.module \template_preprocess_field_collection_item()
Prepares variables for field_collection_item templates.
Default template: field-collection-item.html.twig.
Parameters
array $variables: An associative array containing:
- item: An array of information about the field_collection_item to display.
File
- ./
field_collection.module, line 194 - Module implementing field collection field type.
Code
function template_preprocess_field_collection_item(&$variables) {
$item = $variables['item']['#field_collection_item'];
// Supply useful metadata for the item.
$variables['field_collection_item'] = [
'name' => $item
->bundle(),
'view_mode' => $variables['item']['#view_mode'],
];
// Provide field_collection_item $content variable for the template.
$variables += [
'content' => [],
];
foreach (Element::children($variables['item']) as $key) {
$variables['content'][$key] = $variables['item'][$key];
}
}