The app has some prefixed routes like so:
Router::scope('/ru', function (RouteBuilder $routes) {
$lang = 2;
$routes->setRouteClass(DashedRoute::class);
$routes->connect('/:slug', ['controller' => 'Pages', 'action' => 'pages', 'lang' => $lang])->setPass(['slug']);
$routes->fallbacks(DashedRoute::class);
});
Page in question: http://localhost:8765/ru/smi-o-nas where there are some pagination links using this method:
<?= $this->Paginator->numbers() ?>
It generates links including matched controller and action:
http://localhost:8765/ru/pages/pages/smi-o-nas?page=2
So is it that routes are not set up correctly, or there is an option to make Paginator generate relative links like this:
http://localhost:8765/ru/smi-o-nas?page=2
Looked at the docs, paginator helper code, but all I came up with is setting Paginator config url, which still does no good. Using this:
$this->Paginator->setConfig('options.url', ['controller' => 'ru', 'action' => 'smi-o-nas']);
Simply sticks /ro/smi-o-nas/ in the middle for the link:
http://localhost:8765/ru/ru/smi-o-nas/smi-o-nas?page=2
So do I need to set up routes in a different way, or is there an option for relative urls?
Update I figured out that a relative url would not work for paginator as it will result in urls like "localhost:8765/ru/ru/smi-o-nas/smi-o-nas?page=2?page=3"
Dodgy solution
<?php for($page_number = 1; $page_number <= $this->Paginator->counter("{{pages}}"); $page_number ++):?>
<?php if ($page_number == $this->Paginator->counter("{{page}}")): ?>
<span><?= $page_number ?></span>
<?php else : ?>
<a href="<?= $this->Url->build($this->request->here) ?>?page=<?= $page_number ?>"><?= $page_number ?></a>
<?php endif ; ?>
<?php endfor; ?>