【问题标题】:CakePHP Pagination with HTML Entities not working带有 HTML 实体的 CakePHP 分页不起作用
【发布时间】:2015-04-24 18:07:42
【问题描述】:

谁能给我解个谜。

以下代码产生这个-> http://www.evernote.com/shard/s29/sh/87fce2c2-c323-461b-a5ac-1ccc6d2ba3ad/32b87ce0602a33dfda59c4b9e69be54b

<?php echo $this->Paginator->prev("&lsaquo;", array('escape' => false), null, array('class' => 'pagination_disabled')); ?>
<?php echo $this->Paginator->numbers(array('separator' => '')); ?>    
<?php echo $this->Paginator->next("&rsaquo;", array('escape' => false), null, array('class' => 'pagination_disabled')); ?>

我已清除缓存并尝试将prev 替换为实体编号和next 中使用的完全相同的代码,结果相同。

编辑

嘿,刚刚在 IE 中查看,同样的问题,但按钮颠倒了,prev 按钮呈现正常,但 next 按钮打印参考。奇怪。

【问题讨论】:

    标签: cakephp pagination html-entities


    【解决方案1】:

    我遇到了这个确切的问题,它让我发疯了。

    以下似乎工作正常:

    echo $this->Paginator->prev('&laquo; ', array('escape'=>false), '&laquo; ', array('escape'=>false, 'class' => 'disabled'));
    echo $this->Paginator->numbers(array('separator'=>'&nbsp;'));
    echo $this->Paginator->next(' &raquo;', array('escape'=>false), ' &raquo;', array('escape'=>false, 'class' => 'disabled'));
    

    相信这种行为是有意为之的,但至少对我来说似乎不太合乎逻辑 - 让我知道你的进展情况。

    我不确定具体细节,但nextprev 都有第三个参数。在您的代码中,您有 null - 在我的代码中,我有 &amp;raquo; - 我的版本显示正常。

    string $disabledTitle 可选 NULL 链接禁用时的标题。

    NB 在我的应用中;我的class="disabled" 隐藏了&amp;raquo - 你可能不想要这个。

    【讨论】:

      【解决方案2】:

      PaginatorComponent 期望接收 4 个输入:

      1. 按钮处于活动状态时的标题;
      2. 激活时的选项;
      3. 按钮被禁用时的标题;
      4. 禁用时的选项;

      您可以将第 3 个元素设置为 null,它会在按钮处于活动状态时获取标题,但您仍然需要指定它的选项。因此,您只需要在禁用的按钮选项上添加禁用转义的选项,如下所示:

      <?php echo $this->Paginator->prev("&lsaquo;", array('escape' => false), null, array('class' => 'pagination_disabled', 'escape' => false)); ?>
      <?php echo $this->Paginator->numbers(array('separator' => '')); ?>    
      <?php echo $this->Paginator->next("&rsaquo;", array('escape' => false), null, array('class' => 'pagination_disabled','escape' => false)); ?>
      

      【讨论】:

        猜你喜欢
        • 2013-06-03
        • 2018-04-30
        • 2013-03-02
        • 1970-01-01
        • 2013-09-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多