嗨,我正在尝试在一个Cell中使用Paginator,Paginator工作得很严格,但是单元格模板中的PaginatorHelper不起作用。
我正在使用CakePhp 3.5
这是我的代码
的src /查看/小区/ FinderCell.php
namespace App\View\Cell;
use Cake\View\Cell;
use Cake\Datasource\Paginator;
class FinderCell extends Cell {
public function display() {
$this->loadModel('Pokemon');
$paginador = new Paginator();
$pokemons = $paginador->paginate(
$this->Pokemon->find()
);
$this->set(compact('pokemons'));
}
}
的src /模板/小区/搜索/ display.ctp
<?php
foreach ($pokemons as $pokemon) :
?>
<div class="tipo form large-2 medium-2 columns content">
<?php echo $this->Html->image($pokemon->pokemon_image) ?>
</div>
<?php endforeach; ?>
<div class="paginator">
<ul class="pagination">
<?= $this->Paginator->prev('<< Anterior') ?>
<?= $this->Paginator->numbers() ?>
<?= $this->Paginator->next('Siguiente >>') ?>
</ul>
<p><?= $this->Paginator->counter() ?></p>
</div>
我明白了
答案 0 :(得分:1)
如果你想使用帮助器,那么你需要使用分页参数填充请求对象,这是paginator组件通常会为你做的事情:
// ...
$pagingParams = $paginator->getPagingParams();
$this->set(compact('pokemons', 'pagingParams'));
或paginator helper,它依次设置请求对象上的参数:
$this->Paginator->options(['paging' => $pagingParams]);
String pasteText = null;
Object pasteObj = Display.getInstance()
.getPasteDataFromClipboard();
if (pasteObj instanceof CharSequence) {
pasteText = pasteObj.toString();
}
另见