From c6515a548b3b451c6b3eba0496b2e4a8a264218c Mon Sep 17 00:00:00 2001 From: Thor Brink Date: Mon, 11 Nov 2024 06:36:43 +0000 Subject: [PATCH] refactor: render posts module segment from municipio --- source/php/Module/Posts/Posts.php | 19 +++++++----- .../php/Module/Posts/views/segment.blade.php | 6 +--- .../php/Module/Posts/views/slider.blade.php | 29 ++++++++++++------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/source/php/Module/Posts/Posts.php b/source/php/Module/Posts/Posts.php index 943425b1a..103336ef6 100644 --- a/source/php/Module/Posts/Posts.php +++ b/source/php/Module/Posts/Posts.php @@ -272,15 +272,20 @@ private function renderPostObject(PostObjectInterface $postObject, PostObjectRen * @return array */ protected function getRendererConfig(Appearance $appearance):array { - - if($appearance === Appearance::CollectionItem) { - return [ + return match($appearance) { + Appearance::CollectionItem => [ 'displayFeaturedImage' => in_array('image', $this->fields['posts_fields'] ?? []), 'gridColumnClass' => $this->fields['posts_columns'] ?? [], - ]; - } - - return []; + ], + Appearance::SegmentGridItem => [ + 'reveseColumns' => (bool)(int)$this->fields['image_position'] ?? true, + 'gridColumnClass' => $this->fields['posts_columns'] ?? [], + ], + Appearance::SegmentSliderItem => [ + 'reveseColumns' => (bool)(int)$this->fields['image_position'] ?? true, + ], + default => [], + }; } /** diff --git a/source/php/Module/Posts/views/segment.blade.php b/source/php/Module/Posts/views/segment.blade.php index fea6c362c..e3401aaca 100644 --- a/source/php/Module/Posts/views/segment.blade.php +++ b/source/php/Module/Posts/views/segment.blade.php @@ -4,11 +4,7 @@ @if($posts)
- @foreach ($posts as $post) -
- @include('partials.post.segment') -
- @endforeach + {!! $renderPosts(\Municipio\PostObject\PostObjectRenderer\Appearances\Appearance::SegmentGridItem) !!}
@include('partials.more') diff --git a/source/php/Module/Posts/views/slider.blade.php b/source/php/Module/Posts/views/slider.blade.php index a958c15c0..46c2e2a25 100644 --- a/source/php/Module/Posts/views/slider.blade.php +++ b/source/php/Module/Posts/views/slider.blade.php @@ -26,17 +26,24 @@ ] ]) @foreach ($posts as $key => $post) - @slider__item([ - 'classList' => ['c-slider__item--post'] - ]) - @if ($postsDisplayAs === 'index' || $postsDisplayAs === 'items' || $postsDisplayAs === 'news') - @include('partials.slider.item.index') - @else - @include('partials.slider.item.' . $postsDisplayAs, [ - 'display_reading_time' => $display_reading_time, - ]) - @endif - @endslider__item + + @if($postsDisplayAs === 'segment') + {!! $renderPosts(\Municipio\PostObject\PostObjectRenderer\Appearances\Appearance::SegmentSliderItem) !!} + @else + + @slider__item([ + 'classList' => ['c-slider__item--post'] + ]) + @if ($postsDisplayAs === 'index' || $postsDisplayAs === 'items' || $postsDisplayAs === 'news') + @include('partials.slider.item.index') + @else + @include('partials.slider.item.' . $postsDisplayAs, [ + 'display_reading_time' => $display_reading_time, + ]) + @endif + @endslider__item + + @endif @endforeach @endslider