Files
f3-simple-blog/app/Controllers/SiteController.php
2026-03-28 23:29:06 +01:00

37 lines
972 B
PHP

<?php
declare(strict_types=1);
class SiteController extends BaseController
{
public function home(): void
{
$page = max(1, (int) ($this->f3->get('GET.page') ?? 1));
$media = new Media();
$result = (new Post())->paginateList($page, 12, $media);
$this->render('site/home.html', [
'pageTitle' => 'Accueil',
'posts' => $result['posts'],
'pagination' => $result,
'paginationAlias' => 'home',
], 300);
}
public function show(): void
{
$media = new Media();
$post = (new Post())->findBySlug((string) $this->f3->get('PARAMS.slug'), $media);
if ($post === null) {
$this->f3->error(404, 'Article introuvable.');
return;
}
$this->render('site/post.html', [
'pageTitle' => $post['title'],
'metaDescription' => $post['excerpt'],
'post' => $post,
], 3600);
}
}