Home  >  Article  >  Backend Development  >  How to get the link to the previous and next article in Dedecms

How to get the link to the previous and next article in Dedecms

黄舟
黄舟Original
2017-04-01 09:54:431740browse

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: www.php.cn/xiazai/code/dedecms

Previous article address

The code is as follows:

{dede:prenext get=&#39;pro&#39; runphp="yes"}preg_match_all(&#39;/(.+?)<\/a.*?>/sim&#39;, @me, $strResult, PREG_PATTERN_ORDER);
@me=$strResult[1][0];{/dede:prenext}

Next article address

The code is as follows:

{dede:prenext get=&#39;next&#39; runphp="yes"}preg_match_all(&#39;/(.+?)<\/a.*?>/sim&#39;, @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!

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