Евгений Бунин

PHP, Kohana, Joomla, MySQL, MongoDB, Facebook API

  • Increase font size
  • Default font size
  • Decrease font size

Модуль pagination в Kohana 3.2

После обновления Kohana 3.2 модуль постраничной нумерации перестал работать. Кое как можно поправить ядро, но все же работать он будет криво.
На помощь пришел модуль от https://github.com/kloopko/kohana-pagination. Вот пример как надо его использовать.
1. Дополняем наш маршрут(Route):

Route::set('default', '(<controller>(/<action>(/<id>)))(/page)(/<page>)', array('page'=>'[0-9]+'))
  ->defaults(array(
    'controller' => 'home',
    'action'     => 'index',
  ));
 


2. А в самом контроллере:

    $limit = 20;
    $pagination = Pagination::factory( array(
      'current_page' => array('source' => 'route', 'key' => 'page'),
      'total_items' => $count,
      'items_per_page' => $limit,
      'auto_hide' => false,
      'view' => 'pagination/basic',
      'first_page_in_url' => true
      ))
      ->route_params( array(
        'controller' => Request::current()->controller(),
        'action' => Request::current()->action(),
      ));