How to display the content of custom fields (such as author, source) on the article detail page?

Calendar 👁️ 60

In website operation, the article detail page is not only a place to display core content, but also a key to convey additional information, enhance professionalism and user experience.In addition to the title and text, we often need to display some custom fields on the article detail page, such as author, source, publisher, product model, etc.This information not only enriches the content of the article, but also helps to enhance the authority and credibility of the website, even having a positive impact on SEO optimization and user decision-making.

AnQiCMS (AnQiCMS) with its flexible content model design makes the display of such custom fields very intuitive and powerful.No matter if your website is a corporate website, a self-media blog, or an e-commerce product display, it can easily meet personalized content display needs.

Flexiblely define your custom fields

In AnQi CMS, to display custom fields, you first need to define them in the background.This is thanks to the flexible content model feature provided by Anqi CMS.You can create or modify the corresponding content model based on different content types (such as articles, products, events, etc.)

Log in to the backend, find the 'Content Management' under the 'Content Model' option.Here, you can choose an existing model to edit or create a new model.On the model editing page, you will see a "Content Model Custom Field" area.Here is where we add personalized fields.

When adding custom fields, you can set the "parameter name" (this is the Chinese name displayed to the backend editors, such as "article author"), as well as the "call field" (this is the English name used when calling it in the template, such as 添加自定义字段时,你可以设置“参数名”(这是显示给后台编辑人员看的中文名称,比如“文章作者”),以及“调用字段”(这是在模板中调用时使用的英文名称,比如 添加自定义字段时,你可以设置“参数名”(这是显示给后台编辑人员看的中文名称,比如“文章作者”),以及“调用字段”(这是在模板中调用时使用的英文名称,比如author)。Even better, AnQi CMS supports various field types, such as single-line text, numbers, multi-line text, single selection, multiple selection, and dropdown selection.These rich choices can meet almost all your content structure needs.For example, the author usually chooses 'single-line text', and the source of the article is the same.If you need to display some complex descriptions, such as product features, you can choose 'Multiline text' even enable Markdown editor to provide richer formatting.

Prepare article detail page template

Once the custom fields are defined and filled in the back end, the next step is to display them on the front end of the website's article detail page. The template files for AnQi CMS are usually stored in/templateIn the directory, while the template of the article detail page is usually named{模型table}/detail.html.

The template syntax of Anqi CMS borrows from the Django template engine, using double curly braces{{变量}}To output variable content, use single curly braces and percentages{% 标签 %}Come to process logic and call data. Understanding these basic rules, we can easily embed custom fields into the page.

How to display custom fields on the article detail page

In the article detail page template, we mainly use two powerful tags to retrieve related article data:archiveDetailandarchiveParams.

Directly call the known named custom field

If your custom field has already been set with a clear 'reference field' name (such asauthor/source), then you can directly usearchiveDetailthe tag or through the current document objectarchiveThe direct way to call it.

Suppose you added two custom fields for the "article model" in the background, their "call fields" are respectively.author(author), andsource(Source), and you filled in the content when you published the article. Thendetail.htmlIn the template, you can display them like this:

<article>
    <h1>{{archive.Title}}</h1> {# 这是文章的默认标题 #}
    <div class="article-meta">
        <span>发布时间:{{stampToDate(archive.CreatedTime, "2006-01-02")}}</span>
        <span>浏览量:{{archive.Views}}</span>
        {# 直接调用自定义字段:作者 #}
        {% if archive.author %}
        <span>作者:{% archiveDetail with name="author" %}</span>
        {% endif %}
        {# 直接调用自定义字段:来源 #}
        {% if archive.source %}
        <span>来源:{% archiveDetail with name="source" %}</span>
        {% endif %}
    </div>
    <div class="article-content">
        {%- archiveDetail articleContent with name="Content" %}
        {{articleContent|safe}} {# 文章内容通常包含HTML,需要使用|safe过滤器 #}
    </div>
</article>

You can also express it more concisely byarchiveObject directly accesses the custom field, the effect is the same:

<article>
    <h1>{{archive.Title}}</h1>
    <div class="article-meta">
        <span>发布时间:{{stampToDate(archive.CreatedTime, "2006-01-02")}}</span>
        <span>浏览量:{{archive.Views}}</span>
        {% if archive.author %}
        <span>作者:{{archive.author}}</span>
        {% endif %}
        {% if archive.source %}
        <span>来源:{{archive.source}}</span>
        {% endif %}
    </div>
    <div class="article-content">
        {{archive.Content|safe}}
    </div>
</article>

Here we also added one{% if archive.author %}The judgment, it is a good habit because not all articles will fill in all custom fields, which can prevent unnecessary labels from being displayed when fields are empty.

If your custom field is of 'Multiline text' type and you have set it to support Markdown editing in the backend content model, then when displaying in the template, you need to use|render|safea filter. For example:{{archive.custom_markdown_field|render|safe}}If it is just simple HTML rich text content,|safeit is enough.

Traverse all custom fields (suitable for dynamic display or uncertain field names)

In some scenarios, you may want to dynamically display all the custom parameters of an article in list form, such as a product detail page's 'product parameters' list, where you may not know in advance what parameters will be present. At this time,archiveParamsTags make it very convenient.

archiveParamsTags can retrieve all custom fields and their values of the current article (or a specified ID article) and return them as an iterable array object.

<article>
    <h1>{{archive.Title}}</h1>
    {# ... 文章元信息 ... #}
    <div class="article-params">
        <h3>其他参数</h3>
        <ul>
            {% archiveParams params %} {# params将是一个包含所有自定义字段的数组 #}
            {% for item in params %}
            <li>
                <span>{{item.Name}}:</span> {# item.Name是自定义字段的中文参数名 #}
                <span>{{item.Value}}</span> {# item.Value是自定义字段的值 #}
            </li>
            {% endfor %}
            {% endarchiveParams %}
        </ul>
    </div>
    <div class="article-content">
        {{archive.Content|safe}}
    </div>
</article>

By{% for item in params %}Loop, you can display the names and values of each custom field one by one.This method is very flexible, even if the background content model adds new custom fields, the front-end can automatically display them without modifying the template code.

If you only want to display part of the custom fields, or need to handle some fields specially, you can add conditional judgments in the loop:

<div class="article-params">
    <h3>其他参数</h3>
    <ul>
        {% archiveParams params %}
        {% for item in params %}
            {# 假设我们不想显示“内部备注”这个字段 #}
            {% if item.Name != '内部备注' %}
            <li>
                <span>{{item.Name}}:</span>
                <span>{{item.Value}}</span>
            </li>
            {% endif %}
        {% endfor %}
        {% endarchiveParams %}
    </ul>
</div>

Summary

AnQi CMS makes it very simple to display custom fields on article detail pages with its flexible content model and intuitive template tags.Whether you directly refer to a specific field or dynamically traverse all parameters, you can always find an appropriate implementation.Reasonably utilize these features, not only can it greatly enrich your website content, but also provide visitors with a more comprehensive and professional reading experience.


Frequently Asked Questions (FAQ)

1. Why doesn't the custom field I added in the background and filled in content show on the front page of the article details?

First, make sure that your custom field is correctly defined in the \ Next, check if the custom field you are using is defined correctly in the content model and ensure that there are no spelling errors in the field name. Additionally, verify that you have configured the template for the article detail page (usually Lastly, ensure that your custom field is properly defined in the content model and double-check the spelling of the field name. Also, make sure that the template for the article detail page (usually In conclusion, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Furthermore, confirm that the template for the article detail page (usually Remember to make sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Also, don't forget to confirm that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, ensure that the template for the article detail page (usually To proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually In summary, ensure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually It is important to note that your custom field should be correctly defined in the content model and that the field name is spelled correctly. Moreover, ensure that the template for the article detail page (usually Please ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Additionally, confirm that the template for the article detail page (usually Ensure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually To finalize, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please make sure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to proceed, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, make sure that the template for the article detail page (usually To complete, ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Moreover, confirm that the template for the article detail page (usually Please ensure that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, verify that the template for the article detail page (usually Be sure that your custom field is properly defined in the content model and that the field name is spelled correctly. Furthermore, ensure that the template for the article detail page (usually Ensure that your custom field is accurately defined in the content model and that the field name is spelled correctly. Additionally, make sure that the template for the article detail page (usually In order to continue, verify that your custom field is correctly defined in the content model and that the field name is spelled correctly. Also, ensure that the template for the article detail page (usually{模型table}/detail.htmlUsed the correct template tags to call these fields, for example{% archiveDetail with name="你的调用字段名" %}Or{{archive.你的调用字段名}}Remember to add if the field content may be empty{% if ... %}Determine, to prevent from not displaying. Finally, check whether the system cache has been cleared, sometimes after modifying the template or backend settings, you need to refresh the cache to see the changes on the front end.

2. What types of custom fields are there? What are the differences in how different types are displayed in the template?

The AnQi CMS supports various custom field types, including single-line text, numbers, multi-line text, single selection, multiple selection, and dropdown selection.

  • Single-line text/numberDirectly output its value.
  • Multi-line textIf it contains newline characters or HTML content, it is recommended to use|safeThe filter renders in the correct format. If the Markdown editor is enabled on the backend and Markdown formatting is used, then it is necessary|render|safefilter.
  • Single choice/Multiple choice/Dropdown choiceThese fields' values are usually selected by users and can be directly output. If it is a multi-select type, the output may be a string or an array containing multiple values, which needs to be processed according to the actual output format, for example using|joinThe filter concatenates array elements into a string.

3. How can I make my custom field content support rich text editors or Markdown format like the main content of an article?

When adding or editing custom fields in the background "Content Model", you can choose whether to enable the rich text editor or Markdown editor for "multi-line text" fields.After enabling, this field will have the corresponding editing function during backend editing.When displaying the content of such custom fields in the front-end template, in order to correctly parse and render these formats, you need to use|safeFilter (for HTML rich text content) or|render|safeFilter (for Markdown content),

Related articles

How to get and display a list of recommended articles related to the current article?

In website operation, when we have worked hard to create an article, we naturally hope that it can be seen by more readers and guide them to explore more exciting content.On the bottom or sidebar of the article detail page, cleverly display recommended content related to the current article, which can not only significantly improve the depth and dwell time of users' reading, but also bring many benefits to search engine optimization (SEO).AnQiCMS (AnQiCMS) fully understands this need and provides extremely convenient and powerful tags to help us easily achieve this goal.### Cleverly Utilize `archiveList`

2025-11-08

How to display the link to the previous and next article on the article detail page?

It is an important link in the article detail page of AnQi CMS to display "Previous" and "Next" navigation links, which helps improve the user experience and the internal link structure of the website.This not only guides readers to continue browsing related content and extend their stay time, but also helps search engines better understand the relevance between website content, which has a positive effect on SEO optimization.AnQi CMS provides a user-friendly and powerful template tag system

2025-11-08

How to call and display a document list in a template, and perform sorting and filtering?

Manage and display website content in AnQi CMS, especially document lists, is a very common need in daily operation.Strong and flexible template tags provided by AnQi CMS, allowing us to easily call and display this content on the website front-end, and sort and filter as needed.This article will deeply explore how to use the template function of Anqi CMS to achieve these goals and make your website content display more attractive.### Core Function: `archiveList` tag - Display the basic document content To display the document list

2025-11-08

How to retrieve and display the complete content and images of a specific single page?

Use AnQiCMS to manage and display website content, especially when dealing with independent and rich single-page content such as "About Us" and "Contact Information", its flexibility and powerful functions are particularly prominent.We often need to present the text, images, and even image sets of these pages in their entirety on the website, and AnQiCMS provides a very intuitive way to achieve this. Let's explore together how to retrieve and display the complete content and images of a specific single page in AnQiCMS, making your website content more vivid and diverse.## Content Creation

2025-11-08

How to use Tag tags to associate and display related content on the front end?

In Anqi CMS, content organization and association is the key to enhancing website value, optimizing user experience, and improving search engine performance.In addition to the traditional classification structure, we also have a very powerful and flexible tool - Tag tag.It is like a 'living index' of content, which helps us to connect scattered content in multiple dimensions, making it easier for users to find the information they are interested in.Today, let's talk about how to make full use of Tag tags on the front end to associate and display our wonderful content.### Tag label: Flexible content association bridge Different from a strict classification system

2025-11-08

How to implement the pagination display function of the article comment list?

In website operation, effectively managing and displaying user comments is crucial for enhancing user interaction and content vitality.AnQiCMS (AnQiCMS) is a powerful content management system that provides flexible template tags, allowing us to easily implement pagination display of article comment lists.This article will introduce in detail how to implement this feature through template tags in Anqi CMS, thus providing users with a better browsing experience.Understanding the core of comments and pagination In the Anqi CMS template system, implementing pagination display of article comment lists

2025-11-08

How to display the message form submitted by users on the website?

A highly efficient and flexible mechanism is provided by Anqi CMS to easily display and manage user message forms on your website.Whether it is to collect user feedback, consultation, or simple interactive messages, Anqi CMS can help you quickly implement this function and customize it according to your business needs. ### Learn about the Anqi CMS message function In the Anqi CMS backend management interface, you can find the "Website Message" option under the "Function Management" menu.This is the core area where you manage all comment-related settings, including viewing submitted comments and customizing form fields

2025-11-08

How to call and display the friendship link set in the background on the front end?

AnQiCMS (AnQiCMS) provides a set of intuitive and powerful content management features, among which the management of 'friend links' is an indispensable part of website operation. It not only promotes the SEO performance of the website but also provides users with convenient navigation.This article will give a detailed introduction on how to call and elegantly display the friendship links you set in the background. ### Friend link backend configuration Managing friend links in Anqi CMS is very simple.You just need to log in to the back-end, find the "Function Management" module in the left menu bar, click to enter "Friend Links". Here

2025-11-08