From 7ea5a8c5c20c6b35bf17cae6713b2d3c9195a745 Mon Sep 17 00:00:00 2001 From: stefansl Date: Thu, 7 Nov 2024 11:45:29 +0100 Subject: [PATCH] Improve grid gap class generation and formatting logic. Added checks to ensure that grid gap classes are only generated when values are set, avoiding empty class additions. This update also includes similar conditional checks for formatting gap options, ensuring they are displayed properly only when values are available. --- src/Element/GridStart.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Element/GridStart.php b/src/Element/GridStart.php index 0c2f687..527e963 100644 --- a/src/Element/GridStart.php +++ b/src/Element/GridStart.php @@ -98,9 +98,9 @@ protected function getResponse(Template $template, ContentModel $model, Request $template->gridClasses .= ' '.$model->cp_grid_halign; } - $template->gridClasses .= $this->generateGapClass('mobile', $model->cp_gap_mobile); - $template->gridClasses .= $this->generateGapClass('tablet', $model->cp_gap_tablet); - $template->gridClasses .= $this->generateGapClass('desktop', $model->cp_gap_desktop); + $template->gridClasses .= ($model->cp_gap_mobile) ? $this->generateGapClass('mobile', $model->cp_gap_mobile) : ''; + $template->gridClasses .= ($model->cp_gap_tablet) ? $this->generateGapClass('tablet', $model->cp_gap_tablet) : ''; + $template->gridClasses .= ($model->cp_gap_desktop) ? $this->generateGapClass('desktop', $model->cp_gap_desktop) : ''; return $template->getResponse(); } @@ -121,21 +121,21 @@ private function getConfigInfo(ContentModel $model): string '%s: %s %s, ', $GLOBALS['TL_LANG']['tl_content']['cp_grid_mobile'][0], $GLOBALS['TL_LANG']['tl_content']['cp_grid_options'][$model->cp_grid_mobile], - $this->formatGapOption($model->cp_gap_mobile) + isset($model->cp_gap_mobile) ? $this->formatGapOption($model->cp_gap_mobile) : '' ); $configInfo .= \sprintf( '%s: %s %s, ', $GLOBALS['TL_LANG']['tl_content']['cp_grid_tablet'][0], $GLOBALS['TL_LANG']['tl_content']['cp_grid_options'][$model->cp_grid_tablet], - $this->formatGapOption($model->cp_gap_tablet) + isset($model->cp_gap_tablet) ? $this->formatGapOption($model->cp_gap_tablet) : '' ); $configInfo .= \sprintf( '%s: %s %s, ', $GLOBALS['TL_LANG']['tl_content']['cp_grid_desktop'][0], $GLOBALS['TL_LANG']['tl_content']['cp_grid_options'][$model->cp_grid_desktop], - $this->formatGapOption($model->cp_gap_desktop) + isset($model->cp_gap_desktop) ? $this->formatGapOption($model->cp_gap_desktop) : '' ); $configInfo .= '';