diff --git a/src/Element/GridColumnStart.php b/src/Element/GridColumnStart.php index 837b56a..8b7a54e 100644 --- a/src/Element/GridColumnStart.php +++ b/src/Element/GridColumnStart.php @@ -16,8 +16,10 @@ use Contao\ContentModel; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsContentElement; +use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; /** @@ -31,8 +33,18 @@ #[AsContentElement(type: 'cp_column_start', category: 'cp_grid', template: 'ce_grid_column_start')] class GridColumnStart extends AbstractContentElementController { + public function __construct( + readonly RequestStack $requestStack, + readonly ScopeMatcher $scopeMatcher, + ) { + } + protected function getResponse(Template $template, ContentModel $model, Request $request): Response { + if ($this->scopeMatcher->isBackendRequest()) { + return new Response(''); + } + return $template->getResponse(); } } diff --git a/src/Element/GridColumnStop.php b/src/Element/GridColumnStop.php index 917eb74..972c8ac 100644 --- a/src/Element/GridColumnStop.php +++ b/src/Element/GridColumnStop.php @@ -16,8 +16,10 @@ use Contao\ContentModel; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsContentElement; +use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; /** @@ -28,11 +30,26 @@ * @author Stefan Schulz-Lauterbach */ -#[AsContentElement('cp_column_stop', 'cp_grid', template: 'ce_grid_column_stop')] +#[AsContentElement(type: 'cp_column_stop', category: 'cp_grid', template: 'ce_grid_column_stop')] class GridColumnStop extends AbstractContentElementController { + public function __construct( + readonly RequestStack $requestStack, + readonly ScopeMatcher $scopeMatcher, + ) { + } + protected function getResponse(Template $template, ContentModel $model, Request $request): Response { + if ($this->scopeMatcher->isBackendRequest()) { + return new Response(''); + } + + $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; + if (isset($GLOBALS['TL_CP_GRID'][$parentKey]) && !$GLOBALS['TL_CP_GRID'][$parentKey]['active']) { + $GLOBALS['TL_CP_GRID'][$parentKey]['active'] = true; + } + return $template->getResponse(); } } diff --git a/src/Element/GridStart.php b/src/Element/GridStart.php index 02b0f8a..d8174c2 100644 --- a/src/Element/GridStart.php +++ b/src/Element/GridStart.php @@ -16,8 +16,10 @@ use Contao\ContentModel; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsContentElement; +use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; /** @@ -31,9 +33,19 @@ #[AsContentElement(type: 'cp_grid_start', category: 'cp_grid', template: 'ce_grid_start')] class GridStart extends AbstractContentElementController { + public function __construct( + readonly RequestStack $requestStack, + readonly ScopeMatcher $scopeMatcher, + ) { + } + protected function getResponse(Template $template, ContentModel $model, Request $request): Response { + if ($this->scopeMatcher->isBackendRequest()) { + return new Response(''); + } + $template->gridClasses = ''; $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid; diff --git a/src/Element/GridStop.php b/src/Element/GridStop.php index a4ec8df..1b38408 100644 --- a/src/Element/GridStop.php +++ b/src/Element/GridStop.php @@ -16,8 +16,10 @@ use Contao\ContentModel; use Contao\CoreBundle\Controller\ContentElement\AbstractContentElementController; use Contao\CoreBundle\DependencyInjection\Attribute\AsContentElement; +use Contao\CoreBundle\Routing\ScopeMatcher; use Contao\Template; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use const E_USER_WARNING; @@ -33,8 +35,17 @@ #[AsContentElement(type: 'cp_grid_stop', category: 'cp_grid', template: 'ce_grid_stop')] class GridStop extends AbstractContentElementController { + public function __construct( + readonly RequestStack $requestStack, + readonly ScopeMatcher $scopeMatcher, + ) { + } + protected function getResponse(Template $template, ContentModel $model, Request $request): Response { + if ($this->scopeMatcher->isBackendRequest()) { + return new Response(''); + } $parentKey = ($model->ptable ?: 'tl_article') . '__' . $model->pid;