dede文章頁面如何顯示作者的頭像默認(rèn)只能顯示作者用戶名

字號(hào):


    dede在文章頁面顯示作者只是顯示其用戶名,但是假如我想把dede改造成較為社交化的網(wǎng)站,我覺得是有必要顯示作者的頭像的,但是官方并沒有相應(yīng)的模版標(biāo)簽。
    在網(wǎng)上看到解決這個(gè)問題的辦法基本上是直接在模版頁面調(diào)用runphp的程序段,的確這種辦法是可行的。
    但是我不傾向于這么做,因?yàn)楹芏鄷r(shí)候我們都需要差異化的功能,每次都這樣夾雜著php代碼看起來很亂。
    我是直接在php文件里面修改的,讓文章模版可以調(diào)用幾個(gè)新的標(biāo)簽。
    找到/include/arc.archives.class.php文件
    搜索“$this->addtablerow=$this->dsql->getone($query);”,跳轉(zhuǎn)到大概154行,在else{$this->fields['templet']=$this->fields['redirecturl']='';}下面添加如下代碼:
    代碼如下:
    /*hejie_modify*/
    $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'].'><imgwidth='32'height='32'src='.$this->fields['authorface'].'/></a>;
    $this->fields['authoremail']=$authorinfo['email'];
    這段代碼的作用就是根據(jù)文章的作者id查詢作者信息,其中當(dāng)然包括頭像。
    我這里為了以后備用查詢出了頭像email和用戶名稱三種信息。
    在用戶頭像的這個(gè)標(biāo)簽里面我做了一些處理,使在模版中調(diào)用的時(shí)候能直接生成鏈接,指向作者的空間。
    在文章模板中調(diào)用作者頭像的語句為:
    代碼如下:
    {dede:field.authorface/}
    這個(gè)標(biāo)簽對(duì)應(yīng)的php代碼其實(shí)就是上面的$this->fields['authorface'],同理我們要查詢出作者的email信息其實(shí)是在php代碼的$this->fields['authoremail']中,對(duì)應(yīng)的模版標(biāo)簽為{dede:field.authoremail/}