Fields['authorface']=$authorInfo['face']; under line 154; "That's it.">
How to display the author's avatar on the dede article page?
dede displays the author on the article page only to display his user name, but if I want to transform dede into a more social website, I think it is necessary to display the author's avatar, but the official does not The corresponding template tag.
Recommended study:梦Weavercms
The solution to this problem I saw on the Internet is basically to directly call the runphp program segment on the template page. Indeed, this method It works.
But I don’t tend to do this, because many times we need differentiated functions, and it looks messy to mix PHP code like this every time.
I modified it directly in the php file so that the article template can call several new tags.
Find the /include/arc.archives.class.php file
Search for "$this->addTableRow = $this->dsql->GetOne($query);", Jump to about line 154 and add the following code below else{ $this->Fields['templet'] = $this->Fields['redirecturl'] = '';}:
Code As follows:
/*HEJIE_MODIFY文章作者信息 @www.68cpu.com*/ $query = "SELECT * FROM jcode_member WHERE `mid` = ".$this->Fields['mid']; $authorInfo = $this->dsql->GetOne($query); $this->Fields['authoranme']=$authorInfo['uname']; $this->Fields['authorface']=$authorInfo['face']; if(empty($this->Fields['authorface'])) { $this->Fields['authorface']=($this->authorInfo['sex']=='女')? '../member/templets/images/dfgirl.png' : '../member/templets/images/dfboy.png'; } $this->Fields['authorface']="Fields['authorface']."' />"; $this->Fields['authoremail']=$authorInfo['email'];
The function of this code is to query the author information based on the author id of the article, which of course includes the avatar.
I have provided three types of information: avatar email and user name for future backup.
I did some processing in the tag of the user's avatar so that when called in the template, a link can be directly generated pointing to the author's space.
The statement to call the author's avatar in the article template is:
The code is as follows:
{dede:field.authorface/}
The php code corresponding to this tag is actually the above $this->Fields[ 'authorface'], similarly we want to query the author's email information is actually in $this->Fields['authoremail'] of the php code, and the corresponding template tag is {dede:field.authoremail/}
The above is the detailed content of How to display the author's avatar on the dede article page. For more information, please follow other related articles on the PHP Chinese website!