Home  >  Article  >  Web Front-end  >  dedecms5.7 article realizes secondary development of reading full text function_html/css_WEB-ITnose

dedecms5.7 article realizes secondary development of reading full text function_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:57:341140browse

The full-text reading function is actually available on many popular sites, such as NetEase, Sina, etc. As the content of the article increases, when a page has multiple paginations, this will be displayed. "Read the full text on this page" link. After clicking this link, the article will appear without pagination. , so how to add the full-text reading function to the article content page in dedecms5.7?
As shown in the picture:

What is the use of reading the full text? To put it bluntly, it means improving user experience. Let's see how to implement this function simply.

Modify the file: include/arc.archives.class.php

Note: Back up the original file before making any modifications.

Step one: Open include/arc.archives.class.php

File search: //issystem==-1

Go down about 145 lines to find $this ->Fields['userip'] = $this->addTableRow['userip'];

Add the following line: $this->Fields['body2'] = $this-> addTableRow['body'];

Second step search: $this->dsql->ExecuteNoneQuery("Update `#@__archives` SET ismake=1 WHERE id='".$this-> ;ArcID."'");

Add the following code in the previous line

Copy the code as follows
//Start reading the full text
if($this->TotalPage > ; 1) {
//Use regular matching to remove page breaks
$this->Fields['body2'] = preg_replace('/#p#subtitle#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)
{

//Analyze remote file path
$remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
$localfile = '..'.$remotefile;
//Create a remote folder
$remotedir = preg_replace("#[^\/]*\.html#", '', $remotefile);
$this->ftp->rmkdir ($remotedir);
$this->ftp->upload($localfile, $remotefile, 'ascii');
}
}
//End of reading the full text

Step 3: Find the static page paging list

代码如下 复制代码
/**
* Get the static page paging list
*
* @access public
* @param int $totalPage the total number of pages
* @param int $nowPage the current number of pages
* @param int $aid document id
* @return string
*/
function GetPagebreak($totalPage, $nowPage, $aid)
{
if($totalPage==1)
{
return "";
}
//$PageList = "

  • 共".(www.111cn.net)$totalPage."页:
  • ";
    $PageList = "";
    $nPage = $nowPage-1;
    $lPage = $nowPage 1;
    if($nowPage==1)
    {
    $PageList.="<";
    }
    else
    {
    if($nPage==1)
    {
    $PageList.="<";
    }
    else
    {
    $PageList.="<";
    }
    }
    for($i=1;$i<=$totalPage;$i )
    {
    if($i==1)
    {
    if($nowPage!=1)
    {
    $PageList.="1";
    }
    else
    {
    $PageList.="1";
    }
    }
    else
    {
    $n = $i;
    if($nowPage!=$i)
    {
    $PageList.="".$n."";
    }
    else
    {
    $PageList.="{$n}";
    }
    }
    }
    if($lPage <= $totalPage)
    {
    $PageList.=">";
    }
    else
    {
    $PageList.= ">";
    }
    $PageList.= "阅读全文";
    return $PageList;
    }

    也就是在return $PageList 上一行添加了一行代码,
    $PageList.= "阅读全文";
    修改完成后,保存文件,更新一下页面就可以看到效果了。
    from:http://www.111cn.net/wy/Dedecms/66572.htm

    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:HTML MinifierNext article:HTML Minifier