2017-10-18 400 views
0

這裏是到目前爲止我的代碼:在ZF分頁userid參數添加到路由配置

<?php 
echo $this->paginationControl($this->paginator,'sliding','partial/paginator.phtml',array('route' => 'adminuserlog')); 
?> 

我的錯誤是:

Missing parameter "userid" 

如何去追加的用戶ID參數去的路線部分電話?用戶標識的值爲$this->user->getId()

回答

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">&laquo;</span> 
</a>