Answer the question
In order to leave comments, you need to log in
How to properly configure the router for the pagination module in Kohana?
Good day!
Installed the pagination module for Kohana. It seems to be even.
But I can not properly configure the routes.
Here are all the routes that I have:
Route::set('default', '(<controller>(/<action>(/<id>)))')
->defaults(array(
'controller' => 'main',
'action' => 'index',
));
Route::set('products', '<products>/<id>-<url>', array('id' => '[0-9]+'), array('url' => '.+'), array('page' => '[0-9]+'))
->defaults(array(
'controller' => 'products',
'action' => 'product',
));
Route::set('products', '(<products>(/<action>/<page>(/<id>)))/<page>', array('page' => '[0-9]+'))
->defaults(array(
'controller' => 'products',
'action' => 'index',
));
// пагинация
$count = ORM::factory('product')->count_all();
$content->pagination = Pagination::factory(array('total_items' => $count));
$products = ORM::factory('product')
->limit($content->pagination->items_per_page)
->offset($content->pagination->offset)
->find_all();
<?php defined('SYSPATH') or die('No direct script access.');
return array(
// Application defaults
'default' => array(
'current_page' => array('source' => 'route', 'key' => 'page'), // source: "query_string" or "route"
'total_items' => 0,
'items_per_page' => 2,
'view' => 'pagination/basic',
'auto_hide' => FALSE,
'first_page_in_url' => FALSE,
),
);
Answer the question
In order to leave comments, you need to log in
The links are empty because link building takes the current Route. You have the current default, because it matches any links that consist of 3 segments; and in general it should be the last one.
Plus, your routes are strange, there are 3 nuances 1. <variable> 2. (what may not be in the bracket) 3. everything else is just as it is
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question