hookkeywords + team with role
This commit is contained in:
parent
0726c50993
commit
243583d024
3 changed files with 77 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
|
|
@ -120,11 +120,22 @@
|
|||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if ($team = $page->team()->split()): ?>
|
||||
<?php if (count($team) > 0): ?>
|
||||
<?php if ($team = $page->team()->toStructure()): ?>
|
||||
<?php if ($team->isNotEmpty()): ?>
|
||||
<div class="dl__group">
|
||||
<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>
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue