这似乎应该很简单,但我是CakePHP的新手。也许这只是我应该用良好的HTML编写的东西,但是 - 希望通过CakePHP的HTML帮助程序找到如何做到这一点。
我只想要一个目标=“_空白”的图像链接。
这是我试过的:
<?php echo $this->Html->link($this->Html->image('tmp/728x90.jpg',
    array('alt'=>'advertisement', 'height'=>'90', 
    'width'=>'728')),'http://www.google.com', array('target'=>'_blank')); ?>
(所有在一条线 - 为了方便观看而分手了)
但是当我这样做时,我得到了这个:
<a href="http://www.google.com" target="_blank"><img src="/img/tmp/728x90.jpg" alt="advertisement" height="90" width="728" /></a>
任何帮助是极大的赞赏。
回答 (谢谢deceze)
<?php 
$image = $this->Html->image(
    'tmp/300x600.jpg', 
    array(
        'alt'=>'advertisement', 
        'height'=>'600', 
        'width'=>'300'
    )
);
echo $this->Html->link(
    $image,
    'http://www.google.com', 
    array(
        'target'=>'_blank', 
        'escape' => false
    )
); ?>