diff --git a/site/blueprints/pages/investigation.yml b/site/blueprints/pages/investigation.yml index 9f0d124..e668678 100644 --- a/site/blueprints/pages/investigation.yml +++ b/site/blueprints/pages/investigation.yml @@ -1,4 +1,4 @@ -title: Investigation Summary +title: Investigation tabs: contentTab: @@ -92,7 +92,8 @@ tabs: width: 1/4 incidentCountry: label: Pays de l'incident - type: multiselect + type: tags + max: 1 options: query query: page('database').countries.split width: 1/4 @@ -102,15 +103,15 @@ tabs: width: 1/4 keywords: label: Mots-clés - type: multiselect + type: tags options: query query: page('database').keywords.split width: 1/4 methodologies: label: Méthodologies + type: multiselect options: query query: page('database').methodologies.split - type: multiselect width: 1/4 partners: label: Partenaires @@ -125,8 +126,24 @@ tabs: type: url team: label: Équipe Index - type: multiselect - options: query - query: page('database').team.split - width: 1/4 + type: structure + width: 2/4 + columns: + name: + label: Nom + width: 1/2 + role: + label: Rôle + width: 1/2 + fields: + name: + label: Nom + type: select + options: query + query: page('database').team.split + required: true + role: + label: Rôle + type: text + placeholder: ex. réalisation 3D, textes... seo: seo/page diff --git a/site/config/config.php b/site/config/config.php index df98960..2a6e19e 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -33,5 +33,42 @@ return [ 'campaign_url' => 'https://donorbox.org/soutenir-index-en-2024', 'api_base_url' => 'https://donorbox.org/api/v1' ], - 'tobimori.seo.canonicalBase' => 'https://www.index.ngo' + 'tobimori.seo.canonicalBase' => 'https://www.index.ngo', + + 'hooks' => [ + 'page.update:after' => function ($newPage) { + if ($newPage->intendedTemplate()->name() !== 'investigation') { + return; + } + + $database = page('database'); + if (!$database) { + return; + } + + $fields = [ + 'keywords' => 'keywords', + 'incidentCountry' => 'countries', + ]; + + $updated = false; + $data = []; + + foreach ($fields as $investigationField => $dbField) { + $newValues = $newPage->content()->get($investigationField)->split(); + $existingValues = $database->content()->get($dbField)->split(); + $merged = array_unique(array_merge($existingValues, $newValues)); + + if (count($merged) > count($existingValues)) { + $data[$dbField] = implode(', ', $merged); + $updated = true; + } + } + + if ($updated) { + kirby()->impersonate('kirby'); + $database->update($data); + } + } + ] ]; \ No newline at end of file diff --git a/site/templates/investigation.php b/site/templates/investigation.php index 324fca7..ae79d43 100644 --- a/site/templates/investigation.php +++ b/site/templates/investigation.php @@ -120,11 +120,22 @@ - team()->split()): ?> - 0): ?> + team()->toStructure()): ?> + isNotEmpty()): ?>
Équipe
-
+
name()->esc(); + if ($member->role()->isNotEmpty()) { + $members[] = $name . ' (' . $member->role()->esc() . ')'; + } else { + $members[] = $name; + } + } + echo implode(', ', $members); + ?>