0

我不得不在 CakePHP 中创建我的自定义分页助手,因为 cake 提供的那个不适合我的需要。尽管如此,关于数据检索和每页分组的一切都很好,但是现在当我想在页面底部生成链接(例如,< previousnext >编号)时,我无法使链接按预期工作。

我发现问题在于HtmlHelper转义href部分链接,所以当我通过$this->Html->link()以下方式生成链接时:

$this->Html->link('Next >',array('controller' => 'topic','action' => 'list','page:2'));

它输出:

<a href="http://exam.ple/topic/list/page%3A2">Next &gt;</a>

escape = false作为一个选项也不起作用。

那么有没有办法避免在 HtmlHelper 中的链接中转义 url?

4

1 回答 1

3

它应该是:

$this->Html->link('Next >', 
    array('controller' => 'topic', 'action' => 'list', 'page' => '2'), 
    array('escape' => false));

命名参数需要正确添加为键值对。

这也在文档中。

于 2013-07-30T07:50:38.083 回答