2

I know that my question title sounds like duplicate but it's not. Our project is multi-lingual. I have listing page on this page cakephp pagination is applied. But the link on pagination number is :

http://example.com/controller/action?language=en&page=8

I've implemented routing to disappear action, using below mentioned routing code:

$routes->connect('/controller', 
               ['language' => 'en', 'controller' => 'controller', 'action' => 'action']
    );

so now it is :

http://example.com/controller?language=en&page=8

But my requirement is like this

http://example.com/controller?page=8

To achieve my goal, I have implemented this code

$routes->connect('/controller/:page', 
           ['language' => 'en', 'controller' => 'controller', 'action' => 'action'], ['page' => "(?page:'[0-9]+]')"]
);

Thanks in advance.

1 Answers1

0

You probably have to tweak the PaginatorHelper settings to pass the language parameter to its links.

$this->Paginator->options([
    'url' => [
        'language' => 'en'
    ]
]);

See https://book.cakephp.org/3.0/en/views/helpers/paginator.html#configuring-pagination-options

Marijan
  • 1,825
  • 1
  • 13
  • 18