0
我有一個項目模型,它有很多發票和信用。我試圖在我的ProjectsController的特定函數中對發票和信用信息進行分頁。分頁助手輸出不正確的結果 - cakephp
沒有問題得到正確的信息分頁:
App::Import('Model', 'Invoice');
$this->Invoice = new Invoice;
$this->Paginator->settings = array(
'conditions' => array('Invoice.paid' => 1, 'Invoice.project_id'=>$id),
'limit' => 5
);
$paidInvoices = $this->paginate('Invoice');
App::Import('Model', 'Credit');
$this->Credit = new Credit;
$this->Paginator->settings = array(
'conditions' => array('Credit.project_id' => $id),
'limit' => 3
);
$credits = $this->paginate('Credit');
的問題是,即使我指定的模型像它在文檔中說,第6頁的鏈接將顯示:應該只有2總會成爲下一個鏈接,即使可能沒有頁面訪問。
echo '<div class="right pagination">'.$this->Paginator->first('<< first', array('model'=>'Credit')).
$this->Paginator->prev('< ' . __('previous'), array('model'=>'Credit'), null, array('class' => 'prev disabled')).
$this->Paginator->numbers(array('separator' => '', 'model'=>'Credit')).
$this->Paginator->next(__('next', array('model'=>'Credit')) . ' >', array('model'=>'Credit'), null, array('class' => 'next disabled')).
$this->Paginator->last('last >>', array('model'=>'Credit')).'</div>';