【问题标题】:CakePHP html helper imgage linksCakePHP html 帮助图像链接
【发布时间】:2013-03-23 22:21:58
【问题描述】:

在 Cake 中,我们可以像这样在 image() 中添加 url:
$this->Html->image('image src...', array('url' => 'some address...');
输出为:
<a href="some address..."><img src="image src..." /></a>.

a标签如何添加class和其他属性?

【问题讨论】:

  • 当您需要更多功能时,最好使用链接和图像功能。
  • 好的,谢谢你的回复,我用link()和image();

标签: cakephp html-helper


【解决方案1】:
echo $this->Html->link(
    $this->Html->image($imageSrc, array(
        'class'=>'class_of_image',
        'height' => '50',
        'width' => '100',
        'alt' => 'awesome close-up of me eating pizza'
    )),
    array(
        'controller' => 'your_controller',
        'action' => 'the_action'
    ),
    array(
        'class' => 'class_of_anchor',
        'escape' => false //to allow the image tag within the link
    )
);

您可以随意将它的任何/所有部分写成一行 - 但由于 StackOverflow 的原因,这样更容易阅读。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-13
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    相关资源
    最近更新 更多