... |
... |
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
5 |
5 |
namespace vonRotenberg\CoretoolsBundle\Controller\ContentElement;
|
6 |
6 |
|
7 |
7 |
use Contao\ContentModel;
|
|
8 |
+use Contao\Controller;
|
8 |
9 |
use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController;
|
9 |
10 |
use Contao\CoreBundle\DependencyInjection\Attribute\AsContentElement;
|
10 |
11 |
use Contao\CoreBundle\Twig\FragmentTemplate;
|
... |
... |
@@ -18,6 +19,11 @@ class GridPlacementWrapperController extends AbstractContentElementController
|
18 |
19 |
{
|
19 |
20 |
protected function getResponse(FragmentTemplate $template, ContentModel $model, Request $request): Response
|
20 |
21 |
{
|
|
22 |
+ Controller::loadDataContainer($model->getTable());
|
|
23 |
+ $intDesktopColCount = $GLOBALS['TL_DCA'][$model->getTable()]['fields']['vr_gpw_grid']['eval']['cols'] ?? 12;
|
|
24 |
+ $intTabletColCount = $GLOBALS['TL_DCA'][$model->getTable()]['fields']['vr_gpw_tablet_grid']['eval']['cols'] ?? 12;
|
|
25 |
+ $intMobileColCount = $GLOBALS['TL_DCA'][$model->getTable()]['fields']['vr_gpw_mobile_grid']['eval']['cols'] ?? 12;
|
|
26 |
+
|
21 |
27 |
if (System::getContainer()->get('contao.routing.scope_matcher')->isFrontendRequest($request))
|
22 |
28 |
{
|
23 |
29 |
$GLOBALS['TL_CSS'][] = 'bundles/vonrotenbergcoretools/css/grid-placement-wrapper.min.css|static';
|
... |
... |
@@ -25,19 +31,19 @@ class GridPlacementWrapperController extends AbstractContentElementController
|
25 |
31 |
|
26 |
32 |
// Sicherstellen, dass alle notwendigen Felder vorhanden sind
|
27 |
33 |
// Desktop Grid
|
28 |
|
- $gridCells = $model->vr_gpw_grid ? json_decode($model->vr_gpw_grid) : [];
|
29 |
|
- $intCellStart = !empty($gridCells) ? min($gridCells) : 12;
|
30 |
|
- $intCellEnd = !empty($gridCells) ? max($gridCells) : 12;
|
|
34 |
+ $arrGridCells = $model->vr_gpw_grid ? json_decode($model->vr_gpw_grid) : [];
|
|
35 |
+ $intCellStart = !empty($arrGridCells) ? min($arrGridCells) : $intDesktopColCount;
|
|
36 |
+ $intCellEnd = !empty($arrGridCells) ? max($arrGridCells) : $intDesktopColCount;
|
31 |
37 |
|
32 |
38 |
// Tablet Grid
|
33 |
|
- $tabletGridCells = $model->vr_gpw_tablet_grid ? json_decode($model->vr_gpw_tablet_grid) : [];
|
34 |
|
- $tabletCellStart = !empty($tabletGridCells) ? min($tabletGridCells) : 12;
|
35 |
|
- $tabletCellEnd = !empty($tabletGridCells) ? max($tabletGridCells) : 12;
|
|
39 |
+ $arrTabletGridCells = $model->vr_gpw_tablet_grid ? json_decode($model->vr_gpw_tablet_grid) : [];
|
|
40 |
+ $intTabletCellStart = !empty($arrTabletGridCells) ? min($arrTabletGridCells) : $intTabletColCount;
|
|
41 |
+ $intTabletCellEnd = !empty($arrTabletGridCells) ? max($arrTabletGridCells) : $intTabletColCount;
|
36 |
42 |
|
37 |
43 |
// Mobile Grid
|
38 |
|
- $mobileGridCells = $model->vr_gpw_mobile_grid ? json_decode($model->vr_gpw_mobile_grid) : [];
|
39 |
|
- $mobileCellStart = !empty($mobileGridCells) ? min($mobileGridCells) : 12;
|
40 |
|
- $mobileCellEnd = !empty($mobileGridCells) ? max($mobileGridCells) : 12;
|
|
44 |
+ $arrMobileGridCells = $model->vr_gpw_mobile_grid ? json_decode($model->vr_gpw_mobile_grid) : [];
|
|
45 |
+ $intMobileCellStart = !empty($arrMobileGridCells) ? min($arrMobileGridCells) : $intMobileColCount;
|
|
46 |
+ $intMobileCellEnd = !empty($arrMobileGridCells) ? max($arrMobileGridCells) : $intMobileColCount;
|
41 |
47 |
|
42 |
48 |
|
43 |
49 |
// Vorbereiten der Daten, inklusive der neuen Tablet- und Mobile-Klassen
|
... |
... |
@@ -49,8 +55,8 @@ class GridPlacementWrapperController extends AbstractContentElementController
|
49 |
55 |
'grid_classes' => $this->getGridClasses(12, $intCellStart, $intCellEnd), // Desktop-Klassen
|
50 |
56 |
|
51 |
57 |
// Spezifische Grid-Klassen für Tablet und Mobile
|
52 |
|
- 'grid_tablet_classes' => count($tabletGridCells) ? $this->getGridClasses(12, $tabletCellStart, $tabletCellEnd, 'tablet') : '',
|
53 |
|
- 'grid_mobile_classes' => count($mobileGridCells) ? $this->getGridClasses(12, $mobileCellStart, $mobileCellEnd, 'mobil') : '',
|
|
58 |
+ 'grid_tablet_classes' => count($arrTabletGridCells) ? $this->getGridClasses(12, $intTabletCellStart, $intTabletCellEnd, 'tablet') : '',
|
|
59 |
+ 'grid_mobile_classes' => count($arrMobileGridCells) ? $this->getGridClasses(12, $intMobileCellStart, $intMobileCellEnd, 'mobil') : '',
|
54 |
60 |
]);
|
55 |
61 |
|
56 |
62 |
$template->setData($arrData);
|