2012-02-25 151 views
2

,我有以下的CakePHP代码添加类图像链接

<?php echo $this->Html->image('products/'.$product['Product']['picture'],array('url'=>'/img/products/thumb.big.'.$product['Product']['picture'])); ?> 

上面的代码产生follwoing HTML:

<a href="/oscar-demo/cakephp/img/products/thumb.big.hs_2010_13_a_1920x1200_wallpaper.jpg"> 
    <img alt="" src="/oscar-demo/cakephp/img/products/hs_2010_13_a_1920x1200_wallpaper.jpg"> 
</a> 

但我想在a添加一个类。我该怎么做?

回答

2

可以使用内部链接的图像:

echo $this->Html->link($this->Html->image('products/'.$product['Product']['picture']), '/img/products/thumb.big.'.$product['Product']['picture'], array('class' => 'css-class', 'escape' => false); 
0

我已经创建了的style.css类deleteImg和链接的图像在那个类中,并简单地将类应用于该链接。 ('',array('controller'=>'Mycont','action'=>'deletepic',$ id),数组('confirm'=>'Are你确定要删除图像?','class'=>'deleteImg'));