From 461794e5b9307653f060c78aa742d8d1a706f847 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Thu, 11 Jun 2026 09:58:06 +0100 Subject: [PATCH] Fix Future Ready CSR page rich text and Nova editing. Render hero and about content from Nova with sanitized HTML so bold tags display correctly, and limit the dynamic toggle to resource cards only. Co-authored-by: Cursor --- app/CsrCampaignPage.php | 10 +++++++ app/Nova/CsrCampaignPage.php | 5 ++-- resources/views/static/csr-campaign.blade.php | 30 +++++++------------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/CsrCampaignPage.php b/app/CsrCampaignPage.php index 9ab2c3d0e..b9114d990 100644 --- a/app/CsrCampaignPage.php +++ b/app/CsrCampaignPage.php @@ -3,6 +3,7 @@ namespace App; use Illuminate\Database\Eloquent\Model; +use Stevebauman\Purify\Facades\Purify; class CsrCampaignPage extends Model { @@ -29,6 +30,15 @@ public function resources() return $this->hasMany(CsrCampaignResource::class, 'page_id')->orderBy('position'); } + public static function renderRichText(?string $html): string + { + if ($html === null || trim($html) === '') { + return ''; + } + + return (string) Purify::clean($html); + } + public static function config(): self { $defaults = [ diff --git a/app/Nova/CsrCampaignPage.php b/app/Nova/CsrCampaignPage.php index e4cc40e1c..dbc8df5bb 100644 --- a/app/Nova/CsrCampaignPage.php +++ b/app/Nova/CsrCampaignPage.php @@ -53,7 +53,8 @@ public function fields(Request $request): array return [ ID::make()->onlyOnForms(), Panel::make('General', [ - Boolean::make('Use dynamic content for this page', 'use_dynamic_content'), + Boolean::make('Use dynamic resource cards', 'use_dynamic_content') + ->help('When enabled, the CSR Resources section uses the Resources list below instead of the default cards. Hero and About are always taken from this Nova form.'), ])->collapsable()->collapsedByDefault(), Panel::make('Hero', [ Trix::make('Hero text', 'hero_text')->nullable(), @@ -63,7 +64,7 @@ public function fields(Request $request): array Text::make('Secondary CTA link', 'secondary_cta_link')->nullable(), ])->collapsable()->collapsedByDefault(), Panel::make('About section', [ - Text::make('Title', 'about_title')->nullable(), + Trix::make('Title', 'about_title')->nullable(), Trix::make('Description', 'about_description')->nullable(), ])->collapsable()->collapsedByDefault(), Panel::make('Resources section', [ diff --git a/resources/views/static/csr-campaign.blade.php b/resources/views/static/csr-campaign.blade.php index fd831c531..94241cbca 100644 --- a/resources/views/static/csr-campaign.blade.php +++ b/resources/views/static/csr-campaign.blade.php @@ -110,25 +110,21 @@
- @@ -151,15 +147,11 @@ class="absolute top-0 right-0 h-full max-w-[calc(70vw)] object-cover hidden md:b
-

- {{ $dynamic && $page->about_title ? $page->about_title : __('csr-campaign.about_title') }} +

+ {!! \App\CsrCampaignPage::renderRichText($page?->about_title ?? __('csr-campaign.about_title')) !!}

-
- @if($dynamic && $page->about_description) - {!! $page->about_description !!} - @else - @lang('csr-campaign.about_description') - @endif +
+ {!! \App\CsrCampaignPage::renderRichText($page?->about_description ?? __('csr-campaign.about_description')) !!}

- {{ $dynamic && $page->resources_title ? $page->resources_title : __('csr-campaign.resources') }} + {{ $page?->resources_title ?? __('csr-campaign.resources') }}

@foreach($resourcesToRender as $resource)