zoukankan      html  css  js  c++  java
  • [二次开发]dede文章页面怎样显示作者的头像

    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/}
查看全文
  • 相关阅读:
    用户场景分析
    团队项目个人工作总结(4月22日)
    团队项目个人工作总结(4月21日)
    团队项目个人工作总结(4月20日)
    第九周学习进度情况
    站立会议10-个人总结
    站立会议9-个人总结
    站立会议8-个人总结
    textarea中文提交乱码问题解决
    站立会议7-个人总结
  • 原文地址:https://www.cnblogs.com/ldxsuanfa/p/10667207.html
  • Copyright © 2011-2022 走看看