Zhimeng dedecms introduction example code sharing of how to set the number of characters in the summary

Source: Internet
Author: User
This article describes how to set the number of digest words in dedecms. For more information, see the following article, for more information, see

Dedecms Template: www.php1.cn/xiazai/code/dedecms

In the Dedecms system, the maximum number of words in the article summary (which can be called through the infolen or description-related labels) is set to 250 characters. The main purpose of setting the maximum number is to reduce database redundancy, ensure the good performance of the website. Therefore, it is unreasonable not to set the upper limit for the introduction content, but if the upper limit can be controlled freely, it will play a positive role in the content layout of the webpage. In the process of webpage design, we often need to call the document abstract on the channel list page. if we can effectively control the word count of the document abstract, we can make the page planning very sensitive.

In Dedecms, the methods for calling the abstr on the list page are as follows:

The code is as follows:

1: [field: info/] 2: [field: description/] 3: [field: info function = "cn_substr (@ me, number of characters)"/] 4: [field: description function = "cn_substr (@ me, number of characters)"/]

1st. The two methods are to directly call the abstr. when [field: info/] is used: in arclist infolen = ''} {/dede: arclist}, set the number of characters in the call summary (up to 250 can be set by the system). if [field: description/] is used, the upper limit of digest characters set in the background is used directly. Obviously, both methods are passive and sensitive.

3rd and four methods have completed the sensitive adjustment of the characters displayed in the abstract by using the function. Of course, the four methods are not significantly different when the content of the abstract is not corrected. However, the following describes how to correct this upper limit to demonstrate the importance of [field: description function = "cn_substr (@ me, number of characters.

In Dedecms, php files related to the abstr mainly include:

The code is as follows:

/dede/archives_add.php/dede/archives_edit.php/dede/article_add.php/dede/article_edit.php/dede/article_description_main.php

On the add page, there is a sentence: "$ description = cn_substrR ($ description, $ cfg_auot_description);", which completes [field: description function = "cn_substr (@ me, number of characters. Since this statement is indeed conducive to page planning, we have not corrected it in the experiment.

On the edit page, there is a saying "$ description = cn_substrR ($ description, 250);", which shows a familiar character number "250 ", this is the upper limit of the number of characters in the summary set by the system. For example, if it is gbk encoding, it will show 125 characters. For example, UTF-8 encoding is 81 characters. Obviously, if we want to break the limit on the number of characters in the abstract, we must take it for granted. Yes. modify "250" to another value, for example, "500 ". Here, we do not recommend setting too high. One is that there is no need to show too much content on the list page (it is better to show too much content to directly use the body), and the other is to avoid database redundancy.

It is not enough to complete the above correction. you also need to modify article_description_main.php.

On the article_description_main.php page, find the "if ($ dsize> 250) $ dsize = 250;" statement, which limits the number of characters that can be automatically obtained in the background. Change "250" to "500", that is, to be different from the number of characters previously corrected. (If you confirm that each of your articles is manually added, you do not need to modify this file after you manually obtain the abstract. Automatic summarization is mainly prepared for a large number of articles and collections .)

Finally, log on to the background and change the automatic digest length to 500 in the system-system basic parameters-other options, that is, the number of characters that have been corrected before.

After completing the preceding correction, go to the channel list page and call the channel by tag. The example tag is as follows:

The code is as follows:

{dede:list typeid=” row=’5′ titlelen=’100′ orderby=’new’ pagesize=’5′}[field:title/]

[field:description function=’cn_substr(@me,500)’/]…{/dede:list}

The above is the sample code for the summary setting method of dedecms. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.