CakePHP:ArraySource+;分页器
对于CakePHP,我希望使用带有Paginator组件的数组。我正在使用插件,我创建了一个假模型:CakePHP:ArraySource+;分页器,cakephp,pagination,cakephp-2.3,Cakephp,Pagination,Cakephp 2.3,对于CakePHP,我希望使用带有Paginator组件的数组。我正在使用插件,我创建了一个假模型: 从我的头顶开始,试试这个: $this->Paginator->settings = array( 'order' => array('id DESC'), 'limit' => 2 ); 一点也不确定谢谢@Justin,但不幸的是这不起作用。但正是这种方法根本不起作用。例如,单击“排序”链接都不起作用。相反,分页工作正常。 &l
从我的头顶开始,试试这个:
$this->Paginator->settings = array(
'order' => array('id DESC'),
'limit' => 2
);
一点也不确定谢谢@Justin,但不幸的是这不起作用。但正是这种方法根本不起作用。例如,单击“排序”链接都不起作用。相反,分页工作正常。
<?php
class ExampleController extends AppController {
public $components = array('Paginator');
public $uses = array('Fake');
public function justatest() {
$this->Paginator->settings = array(
'order' => array('id' => 'desc'),
'limit' => 2
);
$records = $this->Paginator->paginate('Fake');
$this->set(compact('records'));
}
<table>
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('name'); ?></th>
<th><?php echo $this->Paginator->sort('height'); ?></th>
<th><?php echo $this->Paginator->sort('width'); ?></th>
</tr>
<?php foreach($records as $v): ?>
<tr>
<td><?php echo $v['Fake']['id']; ?></td>
<td><?php echo $v['Fake']['name']; ?></td>
<td><?php echo $v['Fake']['height']; ?></td>
<td><?php echo $v['Fake']['width']; ?></td>
</tr>
<?php endforeach; ?>
</table>
$this->Paginator->settings = array(
'order' => array('id DESC'),
'limit' => 2
);