'router' => [
'routes' => [
'shop' => [
'type' => Literal::class,
'options' => [
// Change this to something specific to your module
'route' => '/shop/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
'category' => [
'type' => Segment::class,
'options' => [
'route' => 'category/[:action/][:id/]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\CategoryController::class,
'action' => 'index',
]
]
],
// You can place additional routes that match under the
// route defined above here.
],
],
],
],
zblog.local/shop/category/1
zblog.local/shop/category/?page=2, но id должен оставаться так как на нем завязана работа контроллера. Код который отображает пагинатор на странице:
<?= $this->paginationControl($products,
'Sliding',
'application/partial/paginator',
['route' => 'shop/category']); ?>
'router' => [
'routes' => [
/** Configuration of the 'shop' routes. */
'shop' => [
'type' => 'Literal',
'options' => [
'route' => '/shop/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category' routes. */
'category' => [
'type' => 'Literal',
'options' => [
'route' => 'category/',
'defaults' => [
'controller' => Controller\CategoryController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category/action' routes. */
'action' => [
'type' => 'Segment',
'options' => [
'route' => '[:action]',
'constraints' => [
'action' => '(create)',
],
],
],
/** Configuration of the 'shop/category/category' routes. */
'category' => [
'type' => 'Segment',
'options' => [
'route' => '[:id/]',
'constraints' => [
'id' => '[0-9]+',
],
'defaults' => [
'id' => null,
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category/category/action' routes. */
'action' => [
'type' => 'Segment',
'options' => [
'route' => '[:action]',
'constraints' => [
'action' => '(update|delete)',
],
],
],
],
],
],
],
],
],
],
],