Home > Backend Development > PHP Tutorial > 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

黄舟
Release: 2023-03-07 08:50:01
Original
1862 people have browsed it

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}
Copy after login

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}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template