dedecms5.7文章二次開發(fā)實現(xiàn)閱讀全文功能的方法
本文實例講述了dedecms5.7文章二次開發(fā)實現(xiàn)閱讀全文功能的方法。分享給大家供大家參考。具體分析如下:
閱讀全文功能其實在很多的流行站點都有的,比如網(wǎng)易,新浪等,隨著文章內(nèi)容的增加,當一個頁面有多個分頁的時候,就會顯示出這個“在本頁閱讀全文”的鏈接,點擊這個鏈接之后出現(xiàn)的,將是這篇文章以沒有分頁出現(xiàn)的型式,那么在dedecms5.7如何在文章內(nèi)容頁添加閱讀全文功能呢?
這個閱讀全文有什么用呢?說白了,也就是提高用戶體驗,下面讓我們看看,怎么簡單現(xiàn)實這個功能.
修改文件:include/arc.archives.class.php
注意:做任何修改前都要備份好原文件.
第一步:打開include/arc.archives.class.php
文件查找://issystem==-1
往下 大概 145行 找到:
在下面一行添加:
第二步查找:
在上一行添加以下代碼:
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'] = (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)
{
//分析遠程文件路徑
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
$localfile = '..'.$remotefile;
//創(chuàng)建遠程文件夾
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
$this->ftp->rmkdir($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
}
//閱讀全文結(jié)束
第三步:查找 獲得靜態(tài)頁面分頁列表,代碼如下:
* 獲得靜態(tài)頁面分頁列表
*
* @access public
* @param int $totalPage 總頁數(shù)
* @param int $nowPage 當前頁數(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 上一行添加了一行代碼:
修改完成后,保存文件,更新一下頁面就可以看到效果了.
希望本文所述對大家的dedecms建站有所幫助。
欄 目:dedecms
下一篇:dedecms中tags標簽頁偽靜態(tài)化修改技巧
本文標題:dedecms5.7文章二次開發(fā)實現(xiàn)閱讀全文功能的方法
本文地址:http://www.jygsgssxh.com/a1/dedecms/12327.html
您可能感興趣的文章
- 08-05Dedecms5.7版ckeditor網(wǎng)頁編輯器添加中文字體
- 08-05織夢DedeCMS獲取當前欄目文章數(shù)量
- 08-05織夢修改文章排序到第一位如何解決?
- 08-05織夢教程:手把手教你讓dedecms禁止發(fā)布重復(fù)文章
- 08-05織夢教程:批量將文章第一張圖片設(shè)置為文章縮略圖的sql語句
- 08-05織夢DEDECMS調(diào)用文章內(nèi)第一張圖片【非縮略圖】
- 08-05織夢cms文章頁調(diào)用tag關(guān)鍵詞,增加內(nèi)鏈和關(guān)鍵字密度
- 08-05織夢dedecms發(fā)文章上傳圖片提示:Upload filetype not allow 的
- 08-05dedecms教程:獲得某篇文章內(nèi)容的幾種方法
- 08-05織夢教程:修改文章不修改文章發(fā)布時間


閱讀排行
本欄相關(guān)
- 08-05dede:channel currentstyle 失效問題,調(diào)用子
- 08-05網(wǎng)站底部版權(quán)符號怎么打出來?
- 08-05Dedecms文件目錄結(jié)構(gòu)解說(能知道織夢
- 08-05織夢DedeCMS獲取當前欄目文章數(shù)量
- 08-05Dedecms5.7版ckeditor網(wǎng)頁編輯器添加中文
- 08-05織夢模板如何添加和調(diào)用自定義字段
- 08-05DedeCMS后臺模塊列表顯示空白的解決辦
- 08-05DedeCMS自定義字段圖片調(diào)用的問題{de
- 08-05織夢DedeCMS調(diào)用顯示discuz里面主題的方
- 08-05限制織夢會員每天投稿數(shù)量方法
隨機閱讀
- 01-11ajax實現(xiàn)頁面的局部加載
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-10使用C語言求解撲克牌的順子及n個骰子
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 04-02jquery與jsp,用jquery
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05織夢dedecms什么時候用欄目交叉功能?
- 01-10delphi制作wav文件的方法
- 01-10C#中split用法實例總結(jié)


