public function GridStackViews::buildElement in GridStack 8.2
1 call to GridStackViews::buildElement()
- GridStackViews::buildElements in src/
Plugin/ views/ style/ GridStackViews.php - Returns gridstack contents.
File
- src/
Plugin/ views/ style/ GridStackViews.php, line 206
Class
- GridStackViews
- GridStack style plugin.
Namespace
Drupal\gridstack\Plugin\views\styleCode
public function buildElement(array &$box, $row, $delta) {
$settings =& $box['settings'];
$item_id = $settings['item_id'];
$use_category = TRUE;
// Add row/ item classes.
if (!empty($settings['class'])) {
$classes = $this
->getFieldString($row, $settings['class'], $delta);
if (!empty($classes[$delta])) {
$box['attributes']['class'][] = $classes[$delta];
}
}
// Adds the rich box named overlay replacing the main stage to alternate
// boring images with a mix of rich boxes: Slick carousel, any potential
// block_field: video, currency, time, weather, ads, donations blocks, etc.
if (!empty($settings['overlay']) && $this
->getField($delta, $settings['overlay'])) {
$box[$item_id] = $this
->getFieldRendered($delta, $settings['overlay']);
$settings['type'] = 'rich';
$use_category = FALSE;
// As this takes over the entire box contents, nullify extra unused works.
foreach ([
'caption',
'image',
'link',
'overlay',
'title',
] as $key) {
$settings[$key] = '';
}
}
// Adds stamp, such as HTML list of latest news, members, testimonials, etc.
$stamp_index = isset($settings['stamp_index']) ? $settings['stamp_index'] : -1;
if ($delta == $stamp_index && !empty($settings['stamp'])) {
list($view_id, $display_id) = explode(":", $settings['stamp'], 2);
$box['stamp'][$stamp_index] = [
$item_id => views_embed_view($view_id, $display_id),
'settings' => $settings,
'attributes' => isset($box['attributes']) ? $box['attributes'] : [],
];
}
// Overrides parent::buildElement().
parent::buildElement($box, $row, $delta);
// Adds category, must run after parent::buildElement() where captions may
// be nullified.
if ($use_category && !empty($settings['category']) && $this
->getField($delta, $settings['category'])) {
$box['caption']['category'] = $this
->getFieldRendered($delta, $settings['category']);
}
}