Cakephp 3 Paginator – numeracja

Dostęp do parametrów stronicowania dla modelu Phones

$paging = $this->getRequest()->getParam('paging');
$page   = $paging['Phones']['page'];
$limit  = $paging['Phones']['perPage'];
<td class="text-center"><?= ++$ind + (($page -1) * $limit) ?></td>

[Phones] => Array
        (
            [finder] => all
            [page] => 1
            [current] => 41
            [count] => 41
            [perPage] => 50
            [start] => 1
            [end] => 41
            [prevPage] => 
            [nextPage] => 
            [pageCount] => 1
            [sort] => 
            [direction] => 
            [limit] => 
            [sortDefault] => 
            [directionDefault] => 
            [scope] => 
            [completeSort] => Array
                (
                )
        )

Przy zmianie stron paginator numeruje od początku aby uwzgl. limit i kolejne podstrony należy zastosować w widoku:

$page       = $this->request->getQuery('page', 1);

Dalej w tabeli:

<?php foreach ($invoices as $ind => $invoice): ?>
<tr>
  <td><?= ++$ind + $page * $limit ?></td>

Dodaj komentarz