CakePHP 可点击图像

CakePHP Clickable Image

我不确定我做错了什么。到目前为止,这段代码对我不起作用。

这是原代码。如您所见,它只是一张无法点击的图片:

echo $this->Html->image('logo.png', array('alt' => 'Logo', 'id' => 'logo'));

那这就是我现在正在做的事情。我希望徽标可点击,以便将我重定向到 index.ctp。

echo $this->Html->link($this->Html->image('logo.png'), array(
                                'escape' => false,
                                'controller' => 'websites', 
                                'action' => 'index'
                            ));

所以在我的网站上,这个东西显示为 link,徽标应该是:

<img src="/appname/img/logo.png" alt="" />

我的徽标存储在 img 文件夹下。我没有做任何更改,所以我真的不知道这里发生了什么。

echo $this->Html->image("logo.png", 
     array(
            "alt" => "logo",
            'url' => array(
                           'controller' => 'home',
                           'action' => 'index'
             )
     )
 );

输出将是:

<a href="/home/index">
   <img src="/img/logo.png" alt="Logo" />
</a>

阅读更多http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html