添加类图像链接
问题描述:
,我有以下的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
添加一个类。我该怎么做?
答
你为什么不咨询这本书? 它实际上包含了很多的例子正是这种使用案例:
http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::link
答
可以使用内部链接的图像:
echo $this->Html->link($this->Html->image('products/'.$product['Product']['picture']), '/img/products/thumb.big.'.$product['Product']['picture'], array('class' => 'css-class', 'escape' => false);
答
我已经创建了的style.css类deleteImg和链接的图像在那个类中,并简单地将类应用于该链接。 ('',array('controller'=>'Mycont','action'=>'deletepic',$ id),数组('confirm'=>'Are你确定要删除图像?','class'=>'deleteImg'));