現在很多網站尤其是新聞類網站都有閱讀全文功能,當一個頁面有多個分頁的時候就會顯示出這個“在本頁閱讀全文”的鏈接,點擊這個鏈接之后就是這篇文章以沒有分頁出現的形式,那么dedecms5.7如何在文章內容頁也實現這個功能呢?
首先找到并打開/include/arc.archives.class.php文件,在大概第145行左右的位置找到如下代碼:
$this->Fields['userip'] = $this->addTableRow['userip'];
在其下面添加如下代碼:
$this->Fields['body2'] = $this->addTableRow['body'];
添加完成之后再繼續查找如下代碼:
$this->dsql->ExecuteNoneQuery("Update `xiuzhanwang_archives` SET ismake=1 WHERE id='".$this->ArcID."'");
找到后在其上面添加如下代碼:
//閱讀全文開始
if($this->TotalPage > 1) {
//用正則匹配把分頁符去掉
$this->Fields['body2'] = preg_replace('/#p #副標題 #e#/U', '',$this->Fields['body2']);
$this->SplitFields = explode("#p2222#",$this->Fields['body2']);
$this->Fields['tmptitle'] = (empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle']);
$this->Fields['title'] = $this->Fields['tmptitle'];
$this->TotalPage = count($this->SplitFields);
$this->Fields['totalpage'] = $this->TotalPage;
$TRUEfilenameall = $this->GetTruePath().$fileFirst."_all.".$this->ShortName;
$this->ParseDMFields(1,0);
$this->dtp->SaveTo($TRUEfilenameall);
if($cfg_remote_site=='Y' && $isremote == 1)
{
//分析遠程文件路徑
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
$localfile = '..'.$remotefile;
//創建遠程文件夾
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
}
//閱讀全文結束
注:
1、現在很多網站下面這段代碼是有誤的,本站已經做了修正,請注意分辨。
2、下面的織夢DedeCMS5.7二次開發文章頁實現閱讀全文功能的請替換為標準的分頁符,織夢DedeCMS5.7二次開發文章頁實現閱讀全文功能的,就是去掉空格,因為設置為默認分頁符,本文會分頁。
添加完成之后繼續在里面查找獲得靜態頁面分頁列表的代碼,里面有return $PageList;
在其上面添加如下代碼:
$PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>";
修改完成后,生成一下內容頁就可以看到效果了,當文章內容太多分成多頁之后就會在列表后面出現閱讀全文的鏈接了,大家趕快試試吧。
新聞熱點
疑難解答