Dedecms list call the article body content method

Source: Internet
Author: User

When creating a dream weaving template, sometimes we need to call part of the content of the article. The number of words in the [field: description/] label is insufficient (the database design field is varchar (255 ), in addition, the content of the article has been modified, but the abstract still needs to be manually modified. Therefore, only the content of the article body can be called.
There are two methods to call the article body on the DedeCMS list page, but dede: arclist label is used. If dede: list label is used, the first method cannot call the result.

The following is the first method to call the article body on the DedeCMS list page:

The code is as follows: Copy code

{Dede: arclist flag = 'h' row = '10 & prime ;}

<H1> <a href = '[field: arcurl/]'> [field: title/] </a>

<P> [field: id runphp = 'yes'] $ aid = @ me; $ row = $ GLOBALS ['dsql']-> GetOne ("Select body From 'dede _ addonarticle' where aid = '$ aid'"); @ me =

Cn_substr (strip_tags ("{$ row ['body']}"), 400); [/field: id] <a href = '[field: arcurl/] '> [read details] </a> </p> {/dede: arclist}

The number 400 in the code is used to set the amount of content to be called, because the content in the body is called. If there is code in it, it will also be called, which is not good, however, you can use the html2tex () function to solve the problem.

 

The second method is to use the idea that Zhimeng can customize the model content and data, and call the principle to regard the body field of the document template as custom. The call code is as follows:

The code is as follows: Copy code

{Dede: arclist row = '10' addfields = 'body' channelid = '1 '}

<P> [field: body function = 'CN _ substr (html2text (@ me), 600) '/]... </p>

<Span class = "more">

<A href = "[field: arcurl/]" style = "text-decoration: none; color: #990000;" & gt; [details]
</A>
</Span>
{/Dede: arclist}

The following is a detailed description of this method:

1. addrields = "field 1, field 2 ..."

2. idlist: Document Number. The specified content is called.

3. function = 'CN _ substr (html2text (@ me), 600) 'to convert the content of the article to the text format

4. channelid, model number. The default document value is 1. View location: backend-core-content model management

The two methods have their own advantages and disadvantages. The first method is cumbersome and not so easy to understand. We recommend that you use the second method to call the article body function on the DedeCMS list page.

Who said dede: The list tag cannot call the body content, but now I will tell you that it can be called directly

Step 1: Open the background core-> channel model-> Content Model Management-> common articles,

Add the body to the additional field in the list

Step 2: specify addfields = 'body' in the dede: list statement, and then directly use [field: body/] to call all content.

 

Example:

The code is as follows: Copy code
{Dede: list pagesize = '18' addfields = 'body '}
<Li>
<P> [field: body/] </p>
<P> <a href = "[field: arcurl/]" title = "[field: title/]"> [field: title/] </a> </p>
</Li>
{/Dede: list}

In addition, you can use

The code is as follows: Copy code

[Field: body function = 'CN _ substr (html2text (@ me), 200) '/] replace: [field: description/],

Call up the first 200 characters of the article.

After these two steps, you can completely turn off the system's default article summary function.


Finally, there is an official [field: description/] field. This field is sufficient if dozens of characters are required, but it is invalid if there are too many words.

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.