Less home code more F3
This commit is contained in:
@@ -2,28 +2,26 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
class SiteController extends BaseController
|
||||
class SiteController extends Controller
|
||||
{
|
||||
public function home(): void
|
||||
{
|
||||
$page = max(1, (int) ($this->f3->get('GET.page') ?? 1));
|
||||
$media = new Media();
|
||||
$result = (new Post())->paginateList($page, 12, $media);
|
||||
$page = max(1, (int) ($this->f3->get('GET.page') ?: 1));
|
||||
$result = (new Post())->page($page, 12);
|
||||
|
||||
$this->render('site/home.html', [
|
||||
'pageTitle' => 'Accueil',
|
||||
'posts' => $result['posts'],
|
||||
'pagination' => $result,
|
||||
'pageTitle' => 'Articles',
|
||||
'posts' => $result['items'],
|
||||
'pagination' => $result['pagination'],
|
||||
'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.');
|
||||
$post = (new Post())->findBySlug((string) $this->f3->get('PARAMS.slug'));
|
||||
if (!$post) {
|
||||
$this->f3->error(404);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,6 +29,6 @@ class SiteController extends BaseController
|
||||
'pageTitle' => $post['title'],
|
||||
'metaDescription' => $post['excerpt'],
|
||||
'post' => $post,
|
||||
], 3600);
|
||||
], 300);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user