一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

DEDECMS|帝國CMS|Discuz|PHPCMS|Wordpress|ZBLOG|ECSHOP|蘋果CMS|極致CMS|CMS系統(tǒng)|

服務(wù)器之家 - 建站程序 - DEDECMS - dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法

dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法

2019-06-15 11:46DEDECMS教程網(wǎng) DEDECMS

這篇文章主要為大家介紹了dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法,涉及文章模型相關(guān)類文件功能的修改與完善,是一個(gè)比較典型的二次開發(fā)技巧,需要的朋友可以參考下

本文實(shí)例講述了dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法。分享給大家供大家參考。具體分析如下:

閱讀全文功能其實(shí)在很多的流行站點(diǎn)都有的,比如網(wǎng)易,新浪等,隨著文章內(nèi)容的增加,當(dāng)一個(gè)頁面有多個(gè)分頁的時(shí)候,就會(huì)顯示出這個(gè)“在本頁閱讀全文”的鏈接,點(diǎn)擊這個(gè)鏈接之后出現(xiàn)的,將是這篇文章以沒有分頁出現(xiàn)的型式,那么在dedecms5.7如何在文章內(nèi)容頁添加閱讀全文功能呢?

這個(gè)閱讀全文有什么用呢?說白了,也就是提高用戶體驗(yàn),下面讓我們看看,怎么簡單現(xiàn)實(shí)這個(gè)功能.

修改文件:include/arc.archives.class.php

注意:做任何修改前都要備份好原文件.

第一步:打開include/arc.archives.class.php

文件查找://issystem==-1

往下 大概 145行 找到:

復(fù)制代碼
代碼如下:
$this->Fields['userip'] = $this->addTableRow['userip'];

 

在下面一行添加:

復(fù)制代碼
代碼如下:
$this->Fields['body2'] = $this->addTableRow['body'];

 

第二步查找:

復(fù)制代碼
代碼如下:
$this->dsql->ExecuteNoneQuery("Update `dede_archives` SET ismake=1 WHERE id='".$this->ArcID."'");

 

在上一行添加以下代碼:
 

復(fù)制代碼
代碼如下:
//閱讀全文開始 
if($this->TotalPage > 1) { 
//用正則匹配把分頁符去掉 
$this->Fields['body2'] = preg_replace('/# p#副標(biāo)題# e#/U', '',$this->Fields['body2']); 
$this->SplitFields = explode("#p2222#",$this->Fields['body2']); 
$this->Fields['tmptitle'] = (emptyempty($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) 


//分析遠(yuǎn)程文件路徑 
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename); 
$localfile = '..'.$remotefile; 
//創(chuàng)建遠(yuǎn)程文件夾 
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile); 
$this->ftp->rmkdir($remotedir); 
$this->ftp->upload($localfile, $remotefile, 'ascii'); 
}

//閱讀全文結(jié)束

第三步:查找 獲得靜態(tài)頁面分頁列表,代碼如下:

復(fù)制代碼
代碼如下:
/** 
* 獲得靜態(tài)頁面分頁列表 

* @access public 
* @param int $totalPage 總頁數(shù) 
* @param int $nowPage 當(dāng)前頁數(shù) 
* @param int $aid 文檔id 
* @return string 
*/ 
function GetPagebreak($totalPage, $nowPage, $aid) 

if($totalPage==1) 

return ""; 

//$PageList = "<li><a>共".$totalPage."頁: </a></li>"; 
$PageList = ""; 
$nPage = $nowPage-1; 
$lPage = $nowPage+1; 
if($nowPage==1) 

$PageList.="<a href='javascript:void(0);'><</a>"; 

else 

if($nPage==1) 

$PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'><</a>"; 

else 

$PageList.="<a href='".$this->NameFirst."_".$nPage.".".$this->ShortName."' target='_self'><</a>"; 


for($i=1;$i<=$totalPage;$i++) 

if($i==1) 

if($nowPage!=1) 

$PageList.="<a href='".$this->NameFirst.".".$this->ShortName."' target='_self'>1</a>"; 

else 

$PageList.="<a class=\"here\" href='javascript:void(0);' target='_self'>1</a>"; 


else 

$n = $i; 
if($nowPage!=$i) 

$PageList.="<a href='".$this->NameFirst."_".$i.".".$this->ShortName."' target='_self'>".$n."</a>"; 

else 

$PageList.="<a class=\"here\" href='javascript:void(0);' target='_self'>{$n}</a>"; 



if($lPage <= $totalPage) 

$PageList.="<a href='".$this->NameFirst."_".$lPage.".".$this->ShortName."' target='_self'>></a>"; 

else 

$PageList.= "<a href='javascript:void(0);'>></a>"; 

$PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>"; 
return $PageList; 
}

也就是在return $PageList 上一行添加了一行代碼:

復(fù)制代碼
代碼如下:
$PageList.= "<a href='".$this->NameFirst."_all.".$this->ShortName."'>閱讀全文</a>";

 

修改完成后,保存文件,更新一下頁面就可以看到效果了.

希望本文所述對大家的dedecms建站有所幫助。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产成人小视频在线观看 | 爱情岛论坛亚洲一号路线 | 欧美老少| 色男人影院 | 蜜柚精彩在线观看 | 99热这里只有精品在线播放 | 欧美日韩国产一区二区三区不卡 | 精品一区二区三区自拍图片区 | 高清在线一区二区 | 情侣奴伺候女王第2部分小说 | 国产高清不卡码一区二区三区 | 出水小说| 2018高清国产一道国产 | 99久久精品6在线播放 | 青青青国产在线 | 精品视频 久久久 | 国产伦精品一区二区三区免费迷 | china中国小帅gayxnxx | 亚洲精品无码不卡在线观看 | 91亚洲在线 | 国产精品原创巨作无遮挡 | 91久久综合| 精品牛牛影视久久精品 | 四虎精品永久在线网址 | 粉嫩国产14xxxxx0000 | 亚洲高清在线视频 | 成人欧美一区二区三区白人 | 日韩视频在线免费 | 国产成人精品福利色多多 | 成年人视频在线播放 | 日韩aⅴ在线观看 | juy_661佐佐木明希在线播放 | 欧美milk大超乳 | 97午夜 | 美女扒开胸罩露出奶 | 久久中文字幕综合不卡一二区 | 亚洲男人的天堂网 | 欧美特黄视频在线观看 | 日韩欧美高清一区 | 国产欧美日韩专区毛茸茸 | 亚洲色图首页 |