diff --git a/site/blueprints/pages/home.yml b/site/blueprints/pages/home.yml index 80acfda..4942571 100644 --- a/site/blueprints/pages/home.yml +++ b/site/blueprints/pages/home.yml @@ -5,14 +5,37 @@ tabs: label: Contenu icon: page fields: - mainBaseline: - label: Baseline - type: text - help: À gauche des enquêtes. - width: 1/2 - impactsBaseline: - label: Phrase d'introduction des impacts - type: text - help: À gauche des impacts. - width: 1/2 + sections: + label: Sections + type: structure + fields: + baseline: + label: Baseline (colonne gauche) + type: text + width: 1/1 + buttonText: + label: Texte du bouton + type: text + width: 1/2 + buttonLink: + label: Lien du bouton + type: url + width: 1/2 + contentType: + label: Type de contenu + type: select + required: true + options: + investigations: "Enquêtes" + impacts: Impacts + packages: Dossiers + projects: "Projets (Lab)" + news: "Brèves" + width: 1/2 + count: + label: "Nombre d'éléments (min. 4)" + type: number + min: 4 + default: 6 + width: 1/2 seo: seo/page diff --git a/site/templates/home.php b/site/templates/home.php index a7d66c1..045e8cd 100644 --- a/site/templates/home.php +++ b/site/templates/home.php @@ -1,63 +1,88 @@ +language(); +$locale = $lang ? $lang->locale(LC_ALL) : 'fr_FR.UTF-8'; +$dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5); +?>
+sections()->toStructure() as $section): +$type = $section->contentType()->value(); +$count = max(4, (int)$section->count()->value()); -
+[$seeMoreLabel, $seeMoreUrl] = match($type) { + 'investigations' => ['Voir toutes les enquêtes', page('enquetes')->url()], + 'impacts' => ['Voir tous les impacts', page('impacts')->url()], + 'packages' => ['Voir tous les dossiers', page('packages')->url()], + 'projects' => ['Voir tous les projets', site()->find('laboratoire')->url()], + 'news' => ['Voir toutes les brèves', page('news')->url()], + default => ['Voir tout', '/'], +}; +?> + +
- superPinnedInvestigation()->toPage(); - $pinned = $enquetesPage->pinnedInvestigations()->toPages(); - if ($superPin) $pinned = $pinned->not($superPin); + - $list = []; - $shownIds = []; + superPinnedInvestigation()->toPage(); + $pinned = $enquetesPage->pinnedInvestigations()->toPages(); + if ($superPin) $pinned = $pinned->not($superPin); - if ($superPin) { - $list[] = ['page' => $superPin, 'type' => 'super']; - $shownIds[] = $superPin->id(); - } + $list = []; + $shownIds = []; - foreach ($pinned as $p) { - if (count($list) >= 5) break; - $list[] = ['page' => $p, 'type' => 'pinned']; - $shownIds[] = $p->id(); - } - - if (count($list) < 5) { - $latest = $enquetesPage->children()->listed()->sortBy('created', 'desc') - ->filter(fn($p) => !in_array($p->id(), $shownIds)) - ->limit(5 - count($list)); - foreach ($latest as $p) { - $list[] = ['page' => $p, 'type' => 'latest']; + if ($superPin) { + $list[] = ['page' => $superPin, 'type' => 'super']; + $shownIds[] = $superPin->id(); } - } - ?> - cover()->toFile(); - ?> -
+ foreach ($pinned as $p) { + if (count($list) >= $count) break; + $list[] = ['page' => $p, 'type' => 'pinned']; + $shownIds[] = $p->id(); + } - videoPreview()->toFile())): ?> + if (count($list) < $count) { + $latest = $enquetesPage->children()->listed()->sortBy('created', 'desc') + ->filter(fn($p) => !in_array($p->id(), $shownIds)) + ->limit($count - count($list)); + foreach ($latest as $p) { + $list[] = ['page' => $p, 'type' => 'latest']; + } + } + ?> + + cover()->toFile(); + ?> +
+ + videoPreview()->toFile())): ?>
- +
@@ -65,7 +90,7 @@
- +
@@ -79,24 +104,16 @@ incidentDate()->isNotEmpty()): ?>
Date de l'incident
-
+
- partners()->toStructure()): ?> - isNotEmpty()): ?> + partners()->toStructure()) && $partners->isNotEmpty()): ?>
Partenaire(s)
-
- - - name()->value() ?> - - -
+
name()->value(); echo implode(', ', $names) ?>
- incidentLocation()->isNotEmpty()): ?>
@@ -118,112 +135,184 @@
- + - + +
+
+ + children()->listed()->sortBy('created', 'desc')->limit($count) as $impact): + $categories = $impact->category()->split(); + $category = $categories[0] ?? ''; + $cover = $impact->cover()->toFile(); + $investigations = $impact->linkedInvestigations()->toPages(); + ?> + + +
+ + + +
+ children()->listed()->limit($count) as $package): + $cover = $package->cover()->toFile(); + $investigationsCount = $package->linkedContent()->toPages()->count(); + $impactsCount = $package->linkedImpacts()->toPages()->count(); + ?> +
+ +
+ <?= $package->title()->esc() ?> +
+ + +
+

+

+ + + title()->esc() ?> + +

+ + 0 || $impactsCount > 0): ?> +
    + 0): ?> +
  • enquête 1 ? 's' : '' ?>
  • + + 0): ?> +
  • impact 1 ? 's' : '' ?>
  • + +
+ +
+ + + +
+ +
+ + + +
+
+ + find('laboratoire')->children()->listed()->sortBy('created', 'desc')->limit($count) as $project): + $categories = $project->category()->split(); + $category = $categories[0] ?? ''; + $cover = $project->cover()->toFile(); + ?> + + +
+ + + +
+
+ + children()->listed()->sortBy('created', 'desc')->limit($count) as $newsItem): + $categories = $newsItem->category()->split(); + $category = $categories[0] ?? ''; + $cover = $newsItem->cover()->toFile(); + ?> + + +
+ + -
- + +
- - - - - -
-
- -
- -

impactsBaseline() ?>

- - - -
- -
- -
- -
- - children()->listed()->sortBy('created', 'desc')->limit(8) as $impact): - $categories = $impact->category()->split(); - $category = $categories[0] ?? ''; - $cover = $impact->cover()->toFile(); - $investigations = $impact->linkedInvestigations()->toPages(); - ?> - - - -
- - - -
- - -
- - - - - - - +
- \ No newline at end of file +