poznet/arraypaginator

Simple array pagination in view

dev-master 2021-06-15 17:14 UTC

This package is auto-updated.

Last update: 2024-12-16 00:54:49 UTC


README

Simple Array Pagginator Bundle for Symfony 2

SensioLabsInsight

As long as you paginate query elements ( using for example KNP Paginator Bundle ) there is no problem, but sometimes there is a need to paginate array elements in view.

I got problem with implementation KNPPaginatorBundle to paginate elements of array , so i created this.

###Installation Simple : composer require poznet/arraypaginator

###Usage

in parameters

define how much element's you want to show on eah page :

parameters:
    poznet_array_paginator:
      - perpage: 9

in Controller

$tab=array();
$pagination=$this->get('poznet.array.paginator')->paginate($tab);

return array('pagination'=>$pagination);

in View

  • render array elements as normally ( foreach )
  • in place where you want to have pagination add twig function {{ pagination() }}

TODO

in future :

  • some better routing (cofigured by parameters)
  • using views togenerate pagination

Licence

This Bundle is licensed under the MIT License. Feel free to contribute.