1
我正在使用CakePHP。如何向CakePHP中的HTMLHelper中的圖像方法添加屬性到鏈接?
這行代碼會產生<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()
作爲第一個參數,但沒有奏效。
有什麼想法?