too long

Here's my current code within an index.phtml viewscript:

<?= $this->paginationControl($posts,'Sliding','application/partial/paginator', ['route' => 'home','lang'=>'it']); ?>

I'd like to pass the :lang parameter within this paginationControl call so that way the router is notified and the html results show the it lang inside the pagination html ahref code for clickable links.

I'm not quite sure how to correctly do this.

Here's my route:

'home' => [
    'type' => Segment::class,
    'options' => [
        'route'    => '/:lang',
        'defaults' => [
            'controller' => ApplicationIndexController::class,
            'action'     => 'index',
            'lang'       => 'en'
        ],
    ],
],

The resulting html from this paginator will show:

/pp/public/it?page=2

But it currently shows

/pp/public/en?page=2

even when im on the italian version of the page

Well it depends on how you setup your paginationControl partial or viewpage script.

The paginationControl parameters:

PaginationControl::__invoke(Paginator $myPaginator, $scrollingStyle, $partial, $params);

So within your partial or viewpage script for the pagination you are able to access all the stuff you passed to the $params parameter, like you would with your parameters you pass from your controller to your view pages or the partial viewhelper.

You could pass a parameter to the partial like the route to use and its route and query parameters.

$this->paginationControl(
    $posts,
    'sliding',
    'application/partial/pagination',
    [
        'route' => 'home',
        'routeParams' => ['lang' => 'it'], 
        'queryParams' => []
    ]
);

So now within your pagination partial you could use the route, routeParams and queryParams - Template used - Item pagination.

<?php
if (!isset($queryParams)) {
    $queryParams = [];
}
if (!isset($routeParams)) {
    $routeParams = [];
}
?>

<?php if ($this->pageCount): ?>
<div class="paginationControl">
    <?= $this->firstItemNumber; ?> - <?= $this->lastItemNumber; ?>
    <?= $this->translate('of'); ?> <?= $this->totalItemCount; ?>

    <!-- First page link -->
    <?php if (isset($this->previous)): ?>
        <a href="<?= $this->url(
            $this->route,
            $routeParams,
            ArrayUtils::merge($queryParams, ['query' => ['page' => $this->first]])
        ); ?>">
            <?= $this->translate('First'); ?>
        </a> |
    <?php else: ?>
        <span class="disabled"><?= $this->translate('First') ?></span> |
    <?php endif; ?>

    <!-- Previous page link -->
    <?php if (isset($this->previous)): ?>
        <a href="<?= $this->url(
            $this->route,
            $queryParams,
            ArrayUtils::merge($queryParams, ['query' => ['page' => $this->previous]])
        ); ?>">
            &lt; <?= $this->translate('Previous') ?>
        </a> |
    <?php else: ?>
        <span class="disabled">&lt; <?= $this->translate('Previous') ?></span> |
    <?php endif; ?>

    <!-- Next page link -->
    <?php if (isset($this->next)): ?>
        <a href="<?= $this->url(
            $this->route,
            $routeParams,
            ArrayUtils::merge($queryParams, ['query' => ['page' => $this->next]])
        ); ?>">
            <?= $this->translate('Next') ?> &gt;
        </a> |
    <?php else: ?>
        <span class="disabled"><?= $this->translate('Next') ?> &gt;</span> |
    <?php endif; ?>

    <!-- Last page link -->
    <?php if (isset($this->next)): ?>
        <a href="<?= $this->url(
            $this->route,
            $routeParams,
            ArrayUtils::merge($queryParams, ['query' => ['page' => $this->last]])
        ); ?>">
            <?= $this->translate('Last') ?>
        </a>
    <?php else: ?>
        <span class="disabled"><?= $this->translate('Last') ?></span>
    <?php endif; ?>