2017-02-21 40 views
0

我在控制器中有一個動作,我在同一個動作中使用多次使用分頁的cakedc搜索。 第一分頁我想用50的限制和MAXLIMIT,並在第二個我想使用的1000 限制和MAXLIMIT下面是使用代碼Im的一個例子:在我Cakephp和在一個動作中多次使用paginate

$this->Paginator->settings['limit'] = 50; 
$this->Paginator->settings['maxlimit'] = 50; 
$this->set('uuser', $this->paginate()); 
$this->Paginator->settings['limit'] = 1000; 
$this->Paginator->settings['maxlimit'] = 1000; 
$this->set('maxusers',$this->paginate()); 

頁讓我們說索引,我只使用uuser,但問題是它需要1000而不是50的限制和最大限制。 有什麼辦法可以使用uuser變量的限制和maxlimit分頁50和maxusers一個限制和maxlimit分頁數爲1000.因爲maxusers存儲在會話變量中,我沒有在index.ctp頁面中使用它。

感謝

+1

你有什麼問題嗎? – FeedTheWeb

回答

0

這裏是分頁的例子您添加自己的自定義分頁這樣

<div class="paging" style=" background: none repeat scroll 0 0 #60C8F2; 
    float: right; 
    padding: 0 10px; 
    text-align: left; 
    width: auto;"> 
<?php 
$this->Paginator->options(array(
    'url' => array_merge(array(
     'controller' => $this->params['controller'], 
     'action' => $this->params['action'], 
    ) , $this->params['pass'], $this->params['named']) 
)); 

echo $this->Paginator->prev('' . '' , array(
    'class' => 'prev', 
    'escape' => false 
) , null, array(
    'tag' => 'span', 
    'escape' => false, 
    'class' => 'prev' 
)), "\n"; 
echo $this->Paginator->numbers(array(
    'modulus' => 2, 
    'skip' => '', 
    'separator' => " \n", 
    'before' => null, 
    'after' => null, 
    'escape' => false 
)); 
echo $this->Paginator->next('' . '', array(
    'class' => 'next', 
    'escape' => false 
) , null, array(
    'tag' => 'span', 
    'escape' => false, 
    'class' => 'next' 
)), "\n"; 
?> 
</div> 

把這個代碼元素pagination.ctp

調用組件in controller

var $components = array('Paginator'); 

通話分頁到控制器中

$this->paginate = array(
      'limit' => 10, 
      'order' => array(
      'User.created' => 'desc') 

     ); 
     $results = $this->paginate('User'); 

而在CTP文件調用分頁

<?php echo $this->element('pagination'); ?>