This article describes how to get the link of the previous article by Zhimeng dedecms. This article describes how to get the link of the previous article by using PHP, for more information, see the next article. This article describes how to use dedecms to obtain the link from the previous article. This article describes how to use PHP to obtain the link from the previous article. For more information, see
We know that the link and title of the post are called on the post page. by default, dedecms labels for the previous and next posts are {dede: prenext get = 'pre'/} {dede: prenext get = 'next '/}. Sometimes, out of need, we only need a link instead of a title. what should we do? Should we be able to use regular expressions? That's right! The final implementation code is provided below.
Dedecms Template: www.php1.cn/xiazai/code/dedecms
Previous 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 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 for modifying the number of words in the upper and lower articles
Edit and open the include/arc. archives. class. php file.
Search: $ this-> PreNext ['pre'] = "previous: {$ preRow ['title']}";
Add the following code $ preRow ['title'] = cn_substr ($ preRow ['title'], 30) to this line. // A maximum of 15 Chinese characters can be displayed.
Find: $ this-> PreNext ['Next'] = "next: {$ nextRow ['title']}";
Add the following code $ nextRow ['title'] = cn_substr ($ nextRow ['title'], 30) to this line. // A maximum of 15 Chinese characters can be displayed.
Then generate all the pages again.
The above is the detailed content of the method used by Zhimeng dedecms to obtain the link of the next article. For more information, see other related articles in the first PHP community!