diff --git a/site/blueprints/pages/white-papers.yml b/site/blueprints/pages/white-papers.yml index a030ce0..3789fb8 100644 --- a/site/blueprints/pages/white-papers.yml +++ b/site/blueprints/pages/white-papers.yml @@ -67,6 +67,8 @@ tabs: width: 1/4 role: label: Fonction + whitePaper: + label: Livres blancs downloadedAt: label: Date fields: @@ -92,6 +94,11 @@ tabs: type: email translate: false required: true + whitePaper: + label: Livres blancs + type: pages + translate: false + query: site.find('livres-blancs').children downloadedAt: type: text translate: false diff --git a/site/config/routes/download-white-paper.php b/site/config/routes/download-white-paper.php index 21bad77..486b49b 100644 --- a/site/config/routes/download-white-paper.php +++ b/site/config/routes/download-white-paper.php @@ -60,6 +60,8 @@ return [ } } + $pageUuid = $page->uuid()->toString(); + if ($existingIndex !== null) { // Contact déjà présent — on enrichit les champs vides uniquement if ($company !== '' && empty($entries[$existingIndex]['company'])) { @@ -68,6 +70,14 @@ return [ if ($role !== '' && empty($entries[$existingIndex]['role'])) { $entries[$existingIndex]['role'] = $role; } + $whitePapers = $entries[$existingIndex]['whitepaper'] ?? []; + if (!is_array($whitePapers)) { + $whitePapers = array_filter(array_map('trim', explode(',', (string) $whitePapers))); + } + if (!in_array($pageUuid, $whitePapers, true)) { + $whitePapers[] = $pageUuid; + } + $entries[$existingIndex]['whitePaper'] = $whitePapers; } else { $entries[] = [ 'firstName' => $firstName, @@ -75,6 +85,7 @@ return [ 'email' => $email, 'company' => $company, 'role' => $role, + 'whitePaper' => [$pageUuid], 'downloadedAt' => date('d/m/Y H:i'), ]; }