PaginationControl
viewHelper的最後一個參數是將數據傳遞到分頁部分/視圖的方式。
echo $this->paginationControl(
$this->paginator,
'sliding',
'partial/paginator.phtml',
array(
'route' => 'adminuserlog',
'routeParams' => array('userId' => $this->user->getId())
),
);
由於partial/paginator.phtml
只是我們可以通過使用$route
或$this->route
訪問任何視圖變量的圖。
更新您的partial/paginator.phtml
文件包括$routeParams
:
$routeParams = isset($this->routeParams) && is_array($this->routeParams) ? $this->routeParams : [];
$queryParams = isset($this->queryParams) && is_array($this->queryParams) ? $this->queryParams : [];
$urlOptions = ['query' => $queryParams];
// Rendering a button and usage of the URL viewhelper
<a href="<?= $this->url(
$route,
$routeParams,
ArrayUtils::merge($urlOptions, ['query' => ['page' => $this->first]])
); ?>">
<span aria-hidden="true">«</span>
</a>