码迷,mamicode.com
首页 > 其他好文 > 详细

[二次开发]dede文章页面怎样显示作者的头像

时间:2019-04-07 22:28:48      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:csdn   问题   cpu   ==   width   php   处理   his   rda   

dede在文章页面显示作者仅仅是显示其username,可是假如我想把dede改造成较为社交化的站点。我认为是有必要显示作者的头像的,可是官方并没有相应的模版标签。
在网上看到解决问题的办法基本上是直接在模版页面调用runphp的程序段。的确这样的办法是可行的。


可是我不倾向于这么做,由于非常多时候我们都须要差异化的功能。每次都这样夹杂着php代码看起来非常乱。

我是直接在php文件中面改动的。让文章模版能够调用几个新的标签。
找到/include/arc.archives.class.php文件
搜索“$this->addTableRow = $this->dsql->GetOne($query);”,跳转到大概154行,在else{????$this->Fields[‘templet‘] = $this->Fields[‘redirecturl‘] = ‘‘;}以下加入例如以下代码:

/*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‘]="<a href=‘".$GLOBALS[‘cfg_basehost‘]."/member/index.php?uid=".$authorInfo[‘userid‘]."‘><img width=‘32‘ height=‘32‘ src=‘".$this->Fields[‘authorface‘]."‘ /></a>"; $this->Fields[‘authoremail‘]=$authorInfo[‘email‘];


这段代码的作用就是依据文章的作者id查询作者信息,当中当然包含头像。
我这里为了以后备用查询出了头像 email 和username称三种信息。
在用户头像的这个标签里面我做了一些处理,使在模版中调用的时候能直接生成链接,指向作者的空间。
在文章模板中调用作者头像的语句为:
{dede:field.authorface/}
这个标签相应的php代码事实上就是上面的$this->Fields[‘authorface‘]。同理我们要查询出作者的email信息事实上是在php代码的$this->Fields[‘authoremail‘]中,相应的模版标签为{dede:field.authoremail/}

[二次开发]dede文章页面怎样显示作者的头像

标签:csdn   问题   cpu   ==   width   php   处理   his   rda   

原文地址:https://www.cnblogs.com/ldxsuanfa/p/10667207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
分享档案
周排行
mamicode.com排行更多图片
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!