From: Raphaƫl Gertz Date: Tue, 12 Dec 2023 17:38:31 +0000 (+0100) Subject: Add count member X-Git-Tag: 0.2~8 X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/blogbundle/commitdiff_plain/d9a542802b8ccf815f9d11fafc62245dab88a1eb Add count member Add prev and next links --- diff --git a/Controller/AbstractController.php b/Controller/AbstractController.php index 425cdcc..10353cb 100644 --- a/Controller/AbstractController.php +++ b/Controller/AbstractController.php @@ -55,6 +55,11 @@ abstract class AbstractController extends BaseAbstractController implements Serv */ protected array $config; + /** + * Count integer + */ + protected int $count; + /** * Context array */ @@ -76,7 +81,7 @@ abstract class AbstractController extends BaseAbstractController implements Serv protected \DateTime $modified; /** - * Limit integer + * Page integer */ protected int $page; @@ -456,6 +461,21 @@ abstract class AbstractController extends BaseAbstractController implements Serv } } + //With count + if (!empty($this->count)) { + //With prev link + if ($this->page > 0) { + //Set head prev + $parameters['head']['prev'] = $this->generateUrl($this->request->get('_route'), ['page' => $this->page - 1]+$this->request->get('_route_params')); + } + + //With next link + if ($this->count > ($this->page + 1) * $this->limit) { + //Set head next + $parameters['head']['next'] = $this->generateUrl($this->request->get('_route'), ['page' => $this->page + 1]+$this->request->get('_route_params')); + } + } + //Without facebook image defined and texts if (empty($parameters['head']['facebook']['og:image']) && !empty($this->request) && !empty($parameters['head']['fbimage']['texts']) && !empty($this->modified)) { //Get facebook image