2012-11-25 63 views
-1

我有這樣的:修改一塊PHP代碼

<?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> 

無論如何,我能做到嗎?

感謝

+0

確定你可以檢查'htmlLink'的文檔或源代碼,看看你是否可以傳入其他參數;或創建您自己的版本,添加您想要的額外信息。 –

回答

2

這應該工作:

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

謝謝,它的工作,正是我所需要的。 – George

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()); 
+0

非常感謝,它的工作原理。 – George