如何在span tag cakephp中编写带有图像链接的帮助器链接
我想生成这个如何在span tag cakephp中编写带有图像链接的帮助器链接,cakephp,cakephp-2.0,cakephp-2.6,Cakephp,Cakephp 2.0,Cakephp 2.6,我想生成这个 <a href="/users/signup" class="sf-with-ul"> <span class="profile-avatar"> <img alt="" src="img/avatar/anonymous.png" height="40" width="40">
<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>
有什么帮助吗?提前感谢。试试这个:
<?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您可以尝试此操作,只需更改图像路径即可
<?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>';?>
是否希望将echo php标记作为html文档使用html特殊字符of@kelvin请看答案中的代码。我可以将img url保存在varaibale中吗?比如,您在代码中使用了什么模板引擎?