public function SlickManager::buildGrid in Slick Carousel 7.3
Same name and namespace in other branches
- 8.2 src/SlickManager.php \Drupal\slick\SlickManager::buildGrid()
- 8 src/SlickManager.php \Drupal\slick\SlickManager::buildGrid()
Returns items as a grid display.
1 call to SlickManager::buildGrid()
- SlickManager::preRender in src/
SlickManager.php - Builds the Slick instance as a structured array ready for ::renderer().
File
- src/
SlickManager.php, line 375
Class
- SlickManager
- Implements SlickManagerInterface.
Namespace
Drupal\slickCode
public function buildGrid(array $items, array &$settings = []) {
// Enforces unslick with less items. A slideshow should slide, else destroy.
if (empty($settings['unslick']) && !empty($settings['count'])) {
$settings['unslick'] = $settings['count'] < $settings['visible_items'];
}
// Display all items if unslick is enforced for plain grid to lightbox.
if (!empty($settings['unslick'])) {
$settings['display'] = 'main';
$settings['current_item'] = 'grid';
$settings['count'] = 2;
$grids[0] = $this
->buildGridItem($items, 0, $settings);
}
else {
// Otherwise do chunks to have a grid carousel, and also update count.
$preserve_keys = !empty($settings['preserve_keys']);
$grid_items = array_chunk($items, $settings['visible_items'], $preserve_keys);
$settings['count'] = count($grid_items);
foreach ($grid_items as $delta => $grid_item) {
$grids[] = $this
->buildGridItem($grid_item, $delta, $settings);
}
}
return $grids;
}