php - Pagination with placeholder cakephp 3.X -
i have searched 2 days, found no answer. use query placeholders (%$string%) searching customers.
in controller:
` public function searchname() { $data = $this->kunden->find()->where([ 'kunden.name like' => '%'.\filter_input(\input_post, 'name', \filter_default).'%']); $this->set(\compact('data'), $this->paginate($data)); $this->set('_serialize', ['data']); } `
in search_name.ctp:
<?php foreach ($data $suche): ?> <tr> <td><?= $this->number->format($suche->kundennummer,['precision' => 0, 'pattern' => '####']) ?></td> <td><?= h($suche->anrede) ?></td> <td><?= h($suche->name) ?></td> <td><?= h($suche->vorname) ?></td> <td><?= h($suche->ansprechpartner) ?></td> <td><?= h($suche->strasse_nr) ?></td> <td><?= h($suche->plz) ?></td> <td class="actions"> <?= $this->html->link(__('view'), ['action' => 'view', $suche->kundennummer]) ?> <?= $this->html->link(__('edit'), ['action' => 'edit', $suche->kundennummer]) ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <?php $this->paginator->options(array( 'url' => array( 'data' => $data))); ?> <div class="paginator"> <ul class="pagination"> <?= $this->paginator->first('<< ' . __('erste seite')) ?> <?= $this->paginator->prev('< ' . __('vor')) ?> <?= $this->paginator->numbers() ?> <?= $this->paginator->next(__('next') . ' >') ?> <?= $this->paginator->last('>> ' . __('letzte seite')) ?> <?= $this->paginator->number(' ' . __('gehe zu seite:')) ?> </ul> <p><?= $this->paginator->counter() ?></p> </div> </div>
the first page shows list of customers found %$string%, in next pages customers table.
i print array $data foreach pagebuildung, value of placeholder changes first second page.
first page: ... limit 10 offset 0 [params] => array ( [:c0] => array ( [value] => %ab% [type] => [placeholder] => c0 )...
second page: ... limit 10 offset 10 [params] => array ( [:c0] => array ( [value] => %% [type] => [placeholder] => c0 ) ...
what can keep value ?
thank ..
Comments
Post a Comment