Replace GeoformatPage model with a plugin registering coverFiles as a pageMethod (available on all pages) and coverLabel as a fileMethod to display "Carte [title]" for map children files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
19 lines
528 B
PHP
19 lines
528 B
PHP
<?php
|
|
|
|
Kirby::plugin('geoproject/cover-files', [
|
|
'pageMethods' => [
|
|
'coverFiles' => function () {
|
|
return $this->files()->add(
|
|
$this->children()->filterBy('intendedTemplate', 'map')->files()
|
|
);
|
|
}
|
|
],
|
|
'fileMethods' => [
|
|
'coverLabel' => function () {
|
|
if ($this->parent()->intendedTemplate()->name() === 'map') {
|
|
return 'Carte ' . $this->parent()->title();
|
|
}
|
|
return $this->filename();
|
|
}
|
|
]
|
|
]);
|