-1

我有这个:

<?php echo $this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon')); ?>

这会生成一个 HTML 代码,例如:

<a href="http://www.domain.com/john">
  <img src="http://www.domain.com/thumb_0205.jpg" alt="" class="thumb_icon item_photo_user thumb_icon">
</a>

现在,我想做的是添加:

<?php echo $this->viewer()->getTitle(); ?> //This will generate the member's name, like "John Doe" 

到上面的代码,生成一个 HTML 代码,如:

<a href="http://www.domain.com/john">
  <img src="http://www.domain.com/thumb_0205.jpg" alt="" class="thumb_icon item_photo_user thumb_icon">
  <span>John Doe</span>
</a>

反正我能做到吗?

谢谢

4

2 回答 2

2

这应该有效:

<?php echo $this->htmlLink(
    $this->viewer()->getHref(), 
    $this->itemPhoto($this->viewer(), 'thumb.icon') . '<span>' . $this->viewer()->getTitle() . '</span>'
); ?>
于 2012-11-25T09:56:33.930 回答
2

猜猜,这应该工作:

<?php echo $this->htmlLink($this->viewer()->getHref(), $this->itemPhoto($this->viewer(), 'thumb.icon').'<span>'. $this->viewer()->getTitle().'</span>'); ?>

只需将额外的字符串附加到 htmlLink 的第二个参数。

HtmlLink($href, $text, $title = "", array $attribs = array());
于 2012-11-25T09:57:31.867 回答