Weaving Dream Dedecms Article introduction summary How to set the number of words sample code sharing

Source: Internet
Author: User
This article mainly introduces the weaving Dream Dedecms Article introduction summary Word number setting method, need friends can refer to the next

Dedecms template Download Address: www.php.cn/xiazai/code/dedecms

In the DEDECMS system, the article summary (can be called by Infolen or description related tags) is set to a maximum of 250 characters, the main purpose of setting the upper limit is to reduce the database redundancy, to ensure that the site good performance. Therefore, if it is not reasonable to set a limit on the content of the introduction, but if you can control this limit, then the content of the Web page will play a positive role. In the Web page design process, often need to call in the Channel list page to the article summary, if you can effectively control the text of the article summary of words, then can make the page planning is very sensitive.

In Dedecms, the main ways to invoke an article summary on a list page are:

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)"/]

1th, 2 methods are directly invoke the article summary, the number of words in the call problem, when using [Field:info/], can be in {dede:arclist infolen= '}{/dede:arclist}, Sets the number of characters for the call summary (up to 250 of the system setting), and if [field:description/] is used, the upper limit of the digest character set by the background is applied directly. Obviously, both of these approaches are passive and sensitive.

3rd, 4 methods through function functions to complete the presentation of the text Digest character sensitive adjustment. Of course, there is not much difference between the 4 methods when there is no correction to the upper limit of the content of the article summary. However, here's how to fix this upper limit to show the importance of the [Field:description function= cn_substr (@me, number of characters) "/] approach.

In Dedecms, the PHP files associated with the article summary 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); This sentence completes the function of [Field:description function= "Cn_substr (@me, number of characters)"/]. Since this statement does facilitate page planning, we did not modify it in the experiment.

In the edit page, there is a sentence: "$description = CN_SUBSTRR ($description, 250); ", this sentence shows a familiar character number" 250 ", this is the system set the upper limit of the number of article Digest characters. If it is GBK code, it is 125 words. If the Utf-8 code is 81 words. Obviously, we're going to break the upper limit on the number of articles in the abstract. Yes, change "250" to another value here, such as "500". There is no referral set too high, one is not necessary to show too much content on the list page (show too much content is not as direct as the body), and the other is to avoid the database to create redundancy.

Completion of the above correction is not enough, but also needs correction article_description_main.php

On the article_description_main.php page, locate the "if ($dsize >250) $dsize = 250;" statement, which limits the number of characters that automatically get the digest in the background. The "250" here is fixed to "500", that is, the number of characters modified before the difference can be. (If you confirm that each of your articles is manually added, you do not need to fix this file manually to complete the summary acquisition.) Automatic summary acquisition is mostly prepared for a large number of articles and acquisitions. )

Finally, log in to the background, in the system-system fundamental parameters-other options, the automatic summary length, changed to 500, that is, and the number of previously modified characters can be divided.

After we have completed the above corrections, we will go to the Channel List page, which is labeled as follows:

The code is as follows:

{dede:list typeid= "row= ' 5′titlelen= ' 100′orderby= ' new ' pagesize= ' 5′} [Field:title/]</p><p>[field:description function= ' Cn_substr (@me, 500) '/] ... {/dede:list}

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.