]> Raphaël G. Git Repositories - blogbundle/commitdiff
Add count member
authorRaphaël Gertz <git@rapsys.eu>
Tue, 12 Dec 2023 17:38:31 +0000 (18:38 +0100)
committerRaphaël Gertz <git@rapsys.eu>
Tue, 12 Dec 2023 17:38:31 +0000 (18:38 +0100)
Add prev and next links

Controller/AbstractController.php

index 425cdcccaa7d5be66a81dab19abbccdb5eaee477..10353cbf421db5281fb3189231f89e4745624b03 100644 (file)
@@ -55,6 +55,11 @@ abstract class AbstractController extends BaseAbstractController implements Serv
         */
        protected array $config;
 
         */
        protected array $config;
 
+       /**
+        * Count integer
+        */
+       protected int $count;
+
        /**
         * Context array
         */
        /**
         * Context array
         */
@@ -76,7 +81,7 @@ abstract class AbstractController extends BaseAbstractController implements Serv
        protected \DateTime $modified;
 
        /**
        protected \DateTime $modified;
 
        /**
-        * Limit integer
+        * Page integer
         */
        protected int $page;
 
         */
        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
                //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