pagination post
This commit is contained in:
@@ -14,11 +14,12 @@ class PostController extends AbstractController
|
||||
#[Route('/', name: 'app_posts')]
|
||||
public function index(PostRepository $repository, Request $request): Response
|
||||
{
|
||||
$posts = $repository->findPaginatedPosts($request->query->getInt('page',1), 10);
|
||||
$page = $request->query->getInt('page',1);
|
||||
$posts = $repository->findPaginatedPosts($page, 10);
|
||||
return $this->render('post/index.html.twig', [
|
||||
'posts' => $posts,
|
||||
'maxPosts' => $request->query->getInt('page',1) * 10,
|
||||
'currentPage' => $request->query->getInt('maxPosts',1) / 10
|
||||
'maxPosts' => $page * 10,
|
||||
'currentPage' => $page
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user