网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 dede文章页面如何显示作者的头像默认只能显示作者用户名
内容
    dede在文章页面显示作者只是显示其用户名,但是假如我想把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 和用户名称三种信息。
    在用户头像的这个标签里面我做了一些处理,使在模版中调用的时候能直接生成链接,指向作者的空间。
    在文章模板中调用作者头像的语句为:
    代码如下:
    {dede:field.authorface/}
    这个标签对应的php代码其实就是上面的$this->fields['authorface'],同理我们要查询出作者的email信息其实是在php代码的$this->fields['authoremail']中,对应的模版标签为{dede:field.authoremail/}
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/20 21:05:37