hookkeywords + team with role

This commit is contained in:
Julie Blanc 2026-02-14 17:29:27 +01:00
parent 0726c50993
commit 243583d024
3 changed files with 77 additions and 12 deletions

View file

@ -1,4 +1,4 @@
title: Investigation Summary title: Investigation
tabs: tabs:
contentTab: contentTab:
@ -92,7 +92,8 @@ tabs:
width: 1/4 width: 1/4
incidentCountry: incidentCountry:
label: Pays de l'incident label: Pays de l'incident
type: multiselect type: tags
max: 1
options: query options: query
query: page('database').countries.split query: page('database').countries.split
width: 1/4 width: 1/4
@ -102,15 +103,15 @@ tabs:
width: 1/4 width: 1/4
keywords: keywords:
label: Mots-clés label: Mots-clés
type: multiselect type: tags
options: query options: query
query: page('database').keywords.split query: page('database').keywords.split
width: 1/4 width: 1/4
methodologies: methodologies:
label: Méthodologies label: Méthodologies
type: multiselect
options: query options: query
query: page('database').methodologies.split query: page('database').methodologies.split
type: multiselect
width: 1/4 width: 1/4
partners: partners:
label: Partenaires label: Partenaires
@ -125,8 +126,24 @@ tabs:
type: url type: url
team: team:
label: Équipe Index label: Équipe Index
type: multiselect 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 options: query
query: page('database').team.split query: page('database').team.split
width: 1/4 required: true
role:
label: Rôle
type: text
placeholder: ex. réalisation 3D, textes...
seo: seo/page seo: seo/page

View file

@ -33,5 +33,42 @@ return [
'campaign_url' => 'https://donorbox.org/soutenir-index-en-2024', 'campaign_url' => 'https://donorbox.org/soutenir-index-en-2024',
'api_base_url' => 'https://donorbox.org/api/v1' '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);
}
}
]
]; ];

View file

@ -120,11 +120,22 @@
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
<?php if ($team = $page->team()->split()): ?> <?php if ($team = $page->team()->toStructure()): ?>
<?php if (count($team) > 0): ?> <?php if ($team->isNotEmpty()): ?>
<div class="dl__group"> <div class="dl__group">
<dt>Équipe</dt> <dt>Équipe</dt>
<dd><?= implode(', ', array_map('esc', $team)) ?></dd> <dd><?php
$members = [];
foreach ($team as $member) {
$name = $member->name()->esc();
if ($member->role()->isNotEmpty()) {
$members[] = $name . ' (' . $member->role()->esc() . ')';
} else {
$members[] = $name;
}
}
echo implode(', ', $members);
?></dd>
</div> </div>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>