Of course. Let's break down dede_field.content, a very common and important variable in the DedeCMS (织梦CMS) templating system.

What is dede_field.content?
In simple terms, dede_field.content is a PHP variable used in DedeCMS templates to display the full content of an article or a specific custom field.
It's part of DedeCMS's template engine, which uses special tags like {dede:field.content/} to fetch and display data from the database.
The Two Meanings of "Field"
The name can be a bit confusing because "field" can refer to two different things in DedeCMS:
- The
contentField: This specifically refers to the main body text of an article, stored in thedede_arcticletable'sbodyfield. This is the most common usage. - A Custom Field: DedeCMS allows you to add your own fields to an article type (e.g.,
price,author_intro,video_url). In this case,dede_field.contentwould refer to the content of a custom field you namedcontent.
In 99% of cases, when you see {dede:field.content/}, it refers to the main article body.

How to Use It in Templates (Syntax)
You use the field tag within a loop, most commonly the arclist (for article lists) or article (for the full article page) tags.
A. On a Full Article Page (article_article.htm)
This is the most common place to use it. When a user clicks on an article title to read the full post, the article_article.htm template is used. Here, {dede:field.content/} will display the entire content of that specific article.
Example (article_article.htm):
<html>
<head>{dede:field.title/} - {dede:global.cfg_webname/}</title>
</head>
<body>
<h1>{dede:field.title/}</h1>
<div class="info">
发布时间:{dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/}
作者:{dede:field.writer/}
</div>
<hr>
<!-- This is where the full article content is displayed -->
<div class="content">
{dede:field.content/}
</div>
</body>
</html>
B. In an Article List (list_article.htm)
Sometimes, you might want to show a short snippet of the content in a list. You can use the function attribute to limit the number of words.

Example (list_article.htm):
{dede:list pagesize='10'}
<h2><a href="[field:arcurl/]">{dede:field.title/}</a></h2>
<p>
<!-- Display the first 100 characters of the content -->
{dede:field.content function='cn_substr(@me, 100)'}...
</p>
<hr>
{/dede:list}
Note: The function='cn_substr(@me, 100)' part is a DedeCMS function that takes the content (@me), and returns a substring of the first 100 Chinese characters.
Advanced Usage: Modifying the Output with Functions
The real power of {dede:field.content/} comes from using the function attribute. This allows you to process the content before it's displayed on the page. This is extremely useful for things like removing images, handling line breaks, or adding security features.
Common Use Cases:
Removing Images from the Content (for list pages)
To make list pages cleaner, you might want to strip all <img> tags from the content snippet.
{dede:field.content function='RemoveImg(@me)'}
Handling Line Breaks and Paragraphs
The content from the WYSIWYG editor often has simple \n characters. You can convert these into proper HTML <p> or <br> tags.
<!-- Convert \n to <br> -->
{dede:field.content function='nl2br(@me)'}
<!-- A more robust way to create paragraphs -->
{dede:field.content function='html2text(@me)'} <!-- First, strip all HTML -->
{dede:field.content function='MakeHtmlShort(@me, 200)'} <!-- Then, make it short and add paragraphs -->
Note: The exact function for paragraph conversion might depend on your DedeCMS version or custom functions. nl2br is a standard PHP function built into DedeCMS.
Preventing XSS Cross-Site Scripting
It's a security best practice to filter user-generated content to prevent malicious scripts from being executed.
<!-- This will strip all HTML tags, making it safe plain text -->
{dede:field.content function='htmlspecialchars(@me)'}
Calling a Custom PHP Function
You can call any PHP function you have defined. Let's say you have a function in include/common.inc.php called add_copyright($content).
{dede:field.content function='add_copyright(@me)'}
Troubleshooting: Why is {dede:field.content/} Empty?
If you use this tag and nothing appears, here are the most common reasons:
- Wrong Template File: You are using it on a page that doesn't display a single article, like the homepage (
index.htm) or a category list page (list_category.htm). On these pages, you are inside a loop ({dede:list}or{dede:arclist}), so you should use[field:content/]instead. - PHP Short Tags Disabled: DedeCMS relies on PHP short tags (
<? ... ?>). If your server has them disabled, the template engine won't work. Check yourphp.inifile. - Content is Empty: The article itself might have an empty body. Log in to the DedeCMS admin panel and edit the article to make sure there is text in the content editor.
- Caching: DedeCMS uses extensive caching. Sometimes, changes to templates or articles don't appear until you clear the cache. In the admin panel, go to System -> Cache Settings -> Clear All Cache.
Summary Table
| Context | Tag to Use | Description |
|---|---|---|
| Full Article Page | {dede:field.content/} |
Displays the entire content of the single article being viewed. |
| Article List Page | [field:content/] |
Inside a {dede:list} loop, refers to the content of the current article in the list. |
| List Page (with function) | {dede:field.content function='...'} |
Used on a list page to process and display a snippet of the content. |
| Custom Field | {dede:field.xxxxx/} |
Replace xxxxx with the name of your custom field (e.g., {dede:field.price/}). |
