最近,我不得不這樣做非常事,因爲我有過的標籤上,並在每個選項卡是爲每個不同條件下的同一型號的不同分頁表中的一個HTML頁面。
我解決問題的工作方式是創建一個從我想分頁多次模型導出虛擬模型。然後,我簡單地參考了我的分頁的虛擬模型。
例子:
基本型號
class Post extends appmodel { };
假人模型 - 它們使用相同的表作爲基礎模型
class Posts1 extends Post { var $useTable = 'posts'; }
class Posts2 extends Post { var $useTable = 'posts'; }
在你的控制是很重要的
function multiview($id = null) {
$this->paginate['Posts1'] = array(
'conditions'=>array('Posts1.field'=>0),
'limit'=>5
);
$this->set('posts1', $this->paginate('Posts1'));
$this->paginate['Posts2'] = array(
'conditions'=>array('Posts2.field'=>1),
'limit'=>5
);
$this->set('posts2', $this->paginate('Posts2'));
}
然後在你看來
Display first paginated data
<?php foreach ($posts1 as $post): ?>
Do Paginated row display here...
<?php endforeach; ?>
<!-- Shows the page numbers -->
<?php echo $this->Paginator->numbers(array('model'=>'Posts1')); ?>
<!-- Shows the next and previous links -->
<?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?>
<?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>
<!-- prints X of Y, where X is current page and Y is number of pages -->
<?php echo $this->Paginator->counter(); ?>
Display second paginated data
<?php foreach ($posts2 as $post): ?>
Do Paginated row display here...
<?php endforeach; ?>
<!-- Shows the page numbers -->
<?php echo $this->Paginator->numbers(array('model'=>'Posts2')); ?>
<!-- Shows the next and previous links -->
<?php echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled')); ?>
<?php echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled')); ?>
<!-- prints X of Y, where X is current page and Y is number of pages -->
<?php echo $this->Paginator->counter(); ?>
請閱讀我的答案類似的問題:http:// stackoverflow。com/a/21211278/2486198 – Mitja 2014-12-07 18:21:33