Files
f3-simple-blog/app/Controllers/SiteController.php
2026-03-27 20:14:11 +01:00

34 lines
860 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));
$result = (new Post($this->db))->paginateList($page);
$this->renderPublic('site/home.html', [
'pageTitle' => 'Accueil',
'posts' => $result['posts'],
'pagination' => $result,
'paginationAlias' => 'home',
]);
}
public function show(): void
{
$post = (new Post($this->db))->findBySlug((string) $this->f3->get('PARAMS.slug'));
if ($post === null) {
$this->f3->error(404, 'Article introuvable.');
return;
}
$this->renderPublic('site/post.html', [
'pageTitle' => $post['title'],
'post' => $post,
]);
}
}