From 9bf2b97a9b5d9ea1f627545733d993c1731533ce Mon Sep 17 00:00:00 2001 From: polo Date: Mon, 29 Sep 2025 20:56:49 +0200 Subject: =?UTF-8?q?bug=20manque=20d'une=20pr=C3=A9sentation=20par=20d?= =?UTF-8?q?=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/Blocks.php | 6 ++++++ src/view/MainBuilder.php | 5 +++++ src/view/templates/modify_block.php | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/model/Blocks.php b/src/model/Blocks.php index 21e3c18..786ec74 100644 --- a/src/model/Blocks.php +++ b/src/model/Blocks.php @@ -5,7 +5,13 @@ class Blocks{ static public array $blocks = ['post_block' => 'Articles libres', 'news_block' => 'Actualités', //'galery' => 'Galerie', 'calendar' => 'Calendrier', 'form' => 'Formulaire']; + static public array $presentations = ['fullwidth' => 'Pleine largeur', 'grid' => 'Grille', 'mosaic' => 'Mosaïque' //, 'carousel' => 'Carrousel' ]; + + static public function hasPresentation(string $block): bool + { + return in_array($block, ['post_block', 'news_block']) ? true : false; + } } \ No newline at end of file diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index e4f91f3..a04130a 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php @@ -75,6 +75,11 @@ class MainBuilder extends AbstractBuilder if($child_node->getName() === 'news_block'){ $order = $child_node->getNodeData()->getChronoOrder() ? 'chrono' : 'antichrono'; } + + // présentation par défaut + if(Blocks::hasPresentation($child_node->getName()) && $child_node->getNodeData()->getPresentation() === null){ + $child_node->getNodeData()->setPresentation('full_width'); // pas de persistence ici + } ob_start(); require self::VIEWS_PATH . 'modify_block.php'; diff --git a/src/view/templates/modify_block.php b/src/view/templates/modify_block.php index b44327f..1d097e0 100644 --- a/src/view/templates/modify_block.php +++ b/src/view/templates/modify_block.php @@ -30,7 +30,7 @@ if($child_node->getName() === 'news_block'){ getNodeData()->getPresentation() !== null){ +if(Blocks::hasPresentation($child_node->getName())){ ?>
-- cgit v1.2.3