午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法
    來源:易賢網(wǎng) 閱讀:681 次 日期:2015-03-10 10:17:57
    溫馨提示:易賢網(wǎng)小編為您整理了“dedecms5.7文章二次開發(fā)實(shí)現(xiàn)閱讀全文功能的方法”,方便廣大網(wǎng)友查閱!

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

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

    這個(gè)閱讀全文有什么用呢?說白了,也就是提高用戶體驗(yàn),下面讓我們看看,怎么簡(jiǎ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) {

    //用正則匹配把分頁(yè)符去掉

    $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)頁(yè)面分頁(yè)列表,代碼如下:

    復(fù)制代碼代碼如下:/**

    * 獲得靜態(tài)頁(yè)面分頁(yè)列表

    *

    * @access public

    * @param int $totalPage 總頁(yè)數(shù)

    * @param int $nowPage 當(dāng)前頁(yè)數(shù)

    * @param int $aid 文檔id

    * @return string

    */

    function GetPagebreak($totalPage, $nowPage, $aid)

    {

    if($totalPage==1)

    {

    return "";

    }

    //$PageList = "<li><a>共".$totalPage."頁(yè): </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>";

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

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

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看CMS教程
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
    相關(guān)閱讀CMS教程

    2025國(guó)考·省考課程試聽報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)