2

我想生成这个

<a href="/users/signup" class="sf-with-ul">
                                <span class="profile-avatar">
                                    <img alt="" src="img/avatar/anonymous.png" height="40" width="40">
                                </span>
                    </a>

我已经写了

 <?php echo $this->Html->link(
                        $this->Html->image('avatar/anonymous.png',array('height' =>40,'width'=>'40')), array('controller' => 'users', 'action' => 'signup'),
                        array('class' => 'sf-with-ul', 'escape' => false));?>

这会产生

<a href="/users/signup" class="sf-with-ul"><span class="profile-name"></span><img src="/FindTutor/img/avatar/anonymous.png" height="40" width="40" alt="" /></a> 

有什么帮助吗?提前致谢。

4

2 回答 2

1

你可以试试这个只是改变你的图像路径

<?php echo $this->Html->link('<span class="profile-avatar">'. $this->Html->image('home/logo.png',array('width'=>'40px','height'=>'40px'), array('alt' => '')), array('controller' => 'users', 'action' => 'signup' ), array('class' => 'sf-with-ul', 'escape' => false)).'</span>';?>
于 2016-02-21T21:20:41.237 回答
0

尝试这个:

   <?php 

    $img    =   $this->Html->image("avatar/anonymous.png", 
        array("height" => "40", "width" => "40")
    );

    $img_span   =   $this->Html->tag('span', $img, 
        array('class' => 'profile-avatar')
    );

    echo $this->Html->link($img_span, 
        array("controller" => "users", "action" => "signup"),
        array("escape" => false)
    );
?>          

这看起来有点冗长,但更容易理解并且完全符合您的要求。

和平!xD

于 2016-02-21T16:52:10.007 回答