将 html link 转换为 cakephp

Convert html link to cakephp

我该如何转换 html:

<a href="index.html"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a>

对于 cakephp 语言?

喜欢使用和享受类似的东西:

$this->Html->link('foo', array('controller'=>'bar','action'=>'display'))

请注意,虽然 Whosebug 不是 "Write this for me" 或 "convert this for me" 类型的社区,但这是一个简短而直接的问题,所以我会回答它。由于 CakePHP 不支持自定义 HTML 标记创建,您只需将文字放入 link() 调用中,disable HTML entity conversion, as detailed in the docs. 它看起来像:

$this->Html->link('<i class="fa fa-dashboard fa-fw"></i> Dashboard', 'index.html', array('escape'=>FALSE));

这应该完全符合您的要求。一个类似的问题 has been asked before,一如既往地请 RTM。