到目前为止,这是我的代码:
<?php
echo $this->paginationControl($this->paginator,'sliding','partial/paginator.phtml',array('route' => 'adminuserlog'));
?>
我的错误是:
Missing parameter "userid"
如何将userid param附加到呼叫的路由部分?用户ID的值为$this->user->getId()
答案 0 :(得分:0)
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>