Dede How to set the words in the article summary

Source: Internet
Author: User

In the DEDECMS system, the article summary (which 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 redundancy of the database, and ensure the good performance of the website. Therefore, if you do not set an upper limit on the introduction content is obviously unreasonable, but if you have the freedom to control the ceiling, then the content layout of the Web page will have a positive effect. 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 article summary of the word count, then you can make the page layout is flexible.

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

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, in the number of words to invoke, when using [Field:info/], you can in {dede:arclist infolen= '}{/dede:arclist}, Sets the number of characters for the call summary (up to 250 of the system setting), or, if [field:description/] is used, uses the upper limit of the digest character set directly from the background. Obviously, both of these approaches are both passive and inflexible.

3rd, 4 methods through function functions to achieve the text summary display characters flexible adjustment. Of course, there is not much difference between the 4 methods when there is no modification to the upper limit of the article summary content character. However, here's how to modify this upper limit to reflect 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:

/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 implements the function of [Field:description function=" Cn_substr (@me, number of characters) "/]. Because this statement does benefit the page layout, we did not modify it in the experiment.

In the edit page, there is a sentence: "$description = CN_SUBSTRR ($description, 250); ", there is a familiar character number" 250 "in this sentence, which is the upper limit of the number of characters in the system-set article summary. If it is a GBK code, it will show 125 words. If the Utf-8 code is 81 characters. Obviously, we want to break through the article summary of the maximum number of characters, we must take it to the axe. Yes, change "250" to another value here, such as "500". It is not recommended to 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.

It is not enough to complete the above changes, and you need to modify 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. Change the "250" here to "500", which is the same as the number of characters previously modified. (If you confirm that each of your articles is manually added, you do not need to modify this file to manually complete the summary capture.) Automatic summary acquisition is mostly prepared for a large number of articles and acquisitions. )

Finally, the login background, in the system-system basic parameters-other options, the automatic summary length, changed to 500, that is, the number of characters modified before the same.

After we have made the above changes, we will go to the Channel List page, which can be called by tag, and the example tag is as follows:

 {dede:list typeid= "row= ' 5 ' titlelen= '" orderby= ' new ' pagesize= ' 5 '}<h3><a Span style= "color: #ff0000;" >href= ' [field:arcurl/] ' >[field:title/]</a></h3< Span style= "color: #0000ff;" >><p>[field :d escription function= ' Cn_substr (@me, 500) '/] ... </p>{/dede:list}              

Through the above way, we realized the call of the article summary character is 500 characters, completely break through the article abstract 250 characters of the system limitations, for the layout of the page provides a broader space.

Dede How to set the words in the article summary

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: 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.