This article mainly introduces the method of dedecms to get the link to the previous and next article. This article explains how to use PHP to get the link to the previous and next article. Friends who need it can Referring to
, we know that when calling the links and titles of articles before and after the article page, dedecms defaults to the labels of the previous article and the next article as {dede:prenext get='pre '/} {dede:prenext get='next'/}. Sometimes out of necessity, we only need links without titles. How to do this? Everyone should be able to think of using regular expressions, right? That's right! The final implementation code is given below.
dedecms template download address: m.sbmmt.com/xiazai/code/dedecms
Previous article address
The code is as follows:
{dede:prenext get='pro' runphp="yes"}preg_match_all('/(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER); @me=$strResult[1][0];{/dede:prenext}
Next article address
The code is as follows:
{dede:prenext get='next' runphp="yes"}preg_match_all('/(.+?)<\/a.*?>/sim', @me, $strResult, PREG_PATTERN_ORDER); @me=$strResult[1][0];{/dede:prenext}
Extension: Method to modify the number of words in the context chapter
Edit and openinclude/arc. archives.class.php file
Search: $this->PreNext['pre'] = "Previous article: {$preRow['title']} ";
Add the following code above this line $preRow['title']=cn_substr($preRow['title'],30);//Display up to 15 Chinese characters
Search: $this->PreNext['next'] = "Next article: {$nextRow['title']} ";
Add the following code to this line$nextRow['title']=cn_substr($nextRow['title'],30);//Display up to 15 Chinese characters
Then regenerate all pages.
The above is the detailed content of How to get the link to the previous and next article in Dedecms. For more information, please follow other related articles on the PHP Chinese website!