hookkeywords + team with role
This commit is contained in:
parent
0726c50993
commit
243583d024
3 changed files with 77 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue