我正在使用CakePHP。
这行代码将生成<img>
标记:
$html->image('image.png', array('alt', 'Alternative text'));
这将生成相同的内容,但它会使图像可点击:
$html->image('image.png', array('alt' => 'Alternative text', 'url' => 'http://www.example.com'));
到目前为止,我理解,但如果我想在<a>
标记中添加属性,我该怎么办。
这样做:
$html->image('image.png', array('alt' => 'Alternative text', 'url' => 'http://www.example.com/', 'class' => 'aClass'));
将属性添加到<img>
而不是<a>
。输出是这样的:
<a href="http://www.example.com/">
<img src="image.png" alt="Alternative text" class="aClass" />
</a>
但我想要这样的事情:
<a href="http://www.example.com/" class="aClasse">
<img src="image.png" alt="Alternative text" />
</a>
我试图像$html->link()
一样使用$html->image()
作为第一个参数,但它不起作用。
有什么想法吗?
答案 0 :(得分:1)
是的,您需要使用HTML帮助程序link
方法并告诉它不要转义标题,默认情况下会添加'escape' => false
参数。请阅读手册,在那里解释:http://book.cakephp.org/view/1442/link