More robust
This commit is contained in:
@@ -6,30 +6,26 @@ class SiteController extends BaseController
|
||||
{
|
||||
public function home(): void
|
||||
{
|
||||
$this->f3->expire(300); // 5 min — page publique, contenu peu volatile
|
||||
|
||||
$page = max(1, (int) ($this->f3->get('GET.page') ?? 1));
|
||||
$result = (new Post($this->db))->paginateList($page);
|
||||
|
||||
$this->render('site/home.html', [
|
||||
$this->renderPublic('site/home.html', [
|
||||
'pageTitle' => 'Accueil',
|
||||
'posts' => $result['posts'],
|
||||
'pagination' => $result,
|
||||
'paginationBase' => $this->f3->alias('home'),
|
||||
'paginationAlias' => 'home',
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(): void
|
||||
{
|
||||
$this->f3->expire(3600); // 1 h — les articles bougent rarement
|
||||
|
||||
$post = (new Post($this->db))->findBySlug((string) $this->f3->get('PARAMS.slug'));
|
||||
if ($post === null) {
|
||||
$this->f3->error(404, 'Article introuvable.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->render('site/post.html', [
|
||||
$this->renderPublic('site/post.html', [
|
||||
'pageTitle' => $post['title'],
|
||||
'post' => $post,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user