【问题标题】:How to remove « when I am in the current pagination and also » if I am in the last page of pagination using cakephp 3如何删除«当我在当前分页时以及»如果我在使用 cakephp 3 的分页的最后一页
【发布时间】:2018-06-21 12:16:24
【问题描述】:

我想删除

我有这个 index.ctp 我放置分页的地方

<div class="paginator">
        <ul class="pagination">
            <?= $this->Paginator->prev('< ' . __('previous')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('next') . ' >') ?>
        </ul>
        <p><?= $this->Paginator->counter() ?></p>
</div>

这是我在控制器索引方法中的代码

public function index()
{
  $website=  $this->set('websites', $this->paginate());
  $this->set('website', $website);
  $this->set('_serialize', ['website']);
}

这也发生在我想删除的最后一个分页中>>

【问题讨论】:

  • CakePHPs 分页器助手不会生成带有«» 的导航控件,它们必须来自其他地方,可能是插件,也可能是脚本......除非你可以显示它的来源,实在是没法给你一个具体的答案。

标签: cakephp pagination cakephp-3.0


【解决方案1】:

您可以更改分页器组件使用的模板

有很多方法(即从文件加载,如 here 解释的那样)

或者您可以按照here 的说明即时更改:

$this->Paginator->setTemplates([
    'nextDisabled' => '',
    'prevDisabled' => '',
]);

【讨论】:

  • 我的意思是如何删除这个>如果他们没有数据可以显示,
  • 我的代码应该做到这一点。它用空字符串替换了用于禁用的下一个或上一个链接的模板蛋糕
  • 我复制了你的代码,这是警告 .................. 警告 (4096):Cake\View\Helper\PaginatorHelper 类的对象可以不转换为字符串 [APP/Template\Websites\index.ctp, line 64]
  • Template\Websites\index.ctp 的第 64 行是什么样的?
  • @GregSchmidt 这段代码 = $this->Paginator->setTemplates([ 'nextDisabled' => '', 'prevDisabled' => '', ]);?>
猜你喜欢
  • 1970-01-01
  • 2016-04-21
  • 1970-01-01
  • 1970-01-01
  • 2013-08-02
  • 1970-01-01
  • 2017-12-17
  • 2021-11-15
  • 1970-01-01
相关资源
最近更新 更多