dede文章页面如何显示作者的头像?
dede在文章页面显示作者只是显示其用户名,但是假如我想把dede改造成较为社交化的网站,我觉得是有必要显示作者的头像的,但是官方并没有相应的模版标签。
推荐学习:织梦cms
在网上看到解决这个问题的办法基本上是直接在模版页面调用runphp的程序段,的确这种办法是可行的。
但是我不倾向于这么做,因为很多时候我们都需要差异化的功能,每次都这样夹杂着php代码看起来很乱。
我是直接在php文件里面修改的,让文章模版可以调用几个新的标签。
找到/include/arc.archives.class.php文件
搜索“$this->addTableRow=$this->dsql->GetOne($query);”,跳转到大概154行,在else{$this->Fields['templet']=$this->Fields['redirecturl']='';}下面添加如下代码:
代码如下:
$query="SELECT*FROMjcode_memberWHERE`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']="<ahref='".$GLOBALS['cfg_basehost']."/member/index.php?uid=".$authorInfo['userid']."'>@@##@@Fields['authorface']."'/></a>";$this->Fields['authoremail']=$authorInfo['email'];