How to customize fields and display them in Anqi CMS for different content models (such as articles, products)?

Calendar 👁️ 72

AnQi CMS is designed with a flexible content model, making the management and display of website content extremely powerful.In addition to common fields such as article title, publishing time, and content body, we often need to add unique information for specific content types (such as products, news, cases, etc.).For example, a product may require "product model", "color options", "size", while news may require "source of the article" or "author's introduction".The custom field function of AnQi CMS is exactly designed to meet this personalized demand.

This article will provide a detailed guide on how to customize fields for different content models in AnQi CMS, and finally elegantly display this information on the website front-end template.


The first step: understand the value of content models and custom fields

Before we start the configuration, let's first understand the concept of the 'content model' of Anqi CMS.The content model is like the 'skeleton' of content, defining which fields a certain type of content should include.By default, Anqi CMS will be built-in with 'article model' and 'product model' and so on.

The introduction of custom fields has greatly increased the flexibility of content:

  1. Enrich the dimensions of content:Can add 'author introduction', 'specification parameters' for products, etc., to make the content information more comprehensive.
  2. Improve management efficiency:Structure specific information for convenient background editing and management.
  3. Optimize front-end display:You can accurately call and display these custom information in the front-end template, creating a page layout that better meets business needs.

By custom fields, you can build a highly personalized content system according to your business needs.


Step two: Configure custom fields in the Anqi CMS backend.

Configure custom fields is the basis for personalized content display. This process is completed in the "Content Model" management of Anqi CMS.

  1. Enter content model management:Log in to the Anqi CMS backend, find 'Content Management' in the left navigation bar, click to expand and select 'Content Model'.

  2. Select or create a content model:

    • Modify an existing model:You can choose an existing 'Article Model' or 'Product Model' to edit. Click the 'Modify' button next to the model name to enter.
    • Add a custom model:If your business has a new content type, such as "case display", "team members", etc., you can click "Add Model" to create a new content model.Here, you need to define the "model name", "table name" (used for database storage, usually in lowercase English) and "URL alias" (used for front-end URL) for the new model.
  3. Add custom field:After entering the model editing page, you will see the "Content Model Custom Fields" area. Here, you can add exclusive fields for this model:

    • Parameter name:This is the Chinese name displayed in the background for editors, such as 'Article Author', 'Product Model', 'Color Options', etc.
    • Call field:this is the unique identifier referenced in the template, be sure to use lowercase letters such asauthor/productModel/colorsThis name will directly affect the way you call it in the frontend template, so make sure it is concise and identifiable.
    • Field type:The Anqi CMS provides various field types to adapt to different data formats:
      • Single-line text:Suitable for short text input, such as "author", "product model".
      • Number:Input is limited to numbers, such as "inventory amount", "price".
      • Multi-line text:Suitable for long text input, such as "author bio", "product description (rich text)".
      • Single choice, multiple choice, dropdown choice:Applicable when an option needs to be selected from a predefined set, for example, the 'Product Color' can be selected as 'Red, Blue, Green'.When you select these types, you need to enter an option per line in the 'Default Value' area, and the system will automatically parse it as an option.
    • Mandatory?:According to content release requirements, checking this option will force editors to fill in this field.
    • Default:Set a default value for the field. This is where you define all options for single-choice/multiple-choice/dropdown types, one per line.

    After adding the field, remember to click the 'Save' button at the bottom of the page to make the changes take effect.


Step 3: Fill in the custom fields when publishing content.

After you configure the custom fields in the background, these fields will be automatically integrated into the publishing and editing interfaces of the corresponding content models.

For example, if you add the 'article source' and 'author bio' fields to the 'article model':

  1. Click on 'Content Management' under the left-hand navigation bar and edit an existing document after selecting 'Publish Document' or 'Document Management'.
  2. Select or confirm the category to which the document belongs (this category should belong to the content model you have modified).
  3. Scroll the page, within the 'Other Parameters' collapsible area, you will see the newly added custom field.Here, the content editor can fill in the information according to the field type.

Make sure that the content editors understand the purpose of these new fields and fill them in correctly so that the front end can display accurate information.


Step 4: Display custom fields in the front-end template.

Presenting the custom field information filled in the background on the website front-end is a key step in achieving personalized display.The Anqi CMS template system provides flexible tags to complete this task.

The template files of AnQi CMS are usually stored in/templateUnder the directory, and use syntax similar to the Django template engine. You need to find the template file for the corresponding content model detail page, for example, the article detail page might be{模型table}/detail.htmlorarchive/detail.htmlProduct detail page may beproduct/detail.html.

In these template files, you can use the following two main methods to display custom fields:

Method one: througharchiveDetailTag direct call (for known field names)

If you exactly know the name of the custom field's "reference field" and the field only contains simple text or numbers, you can use it directlyarchiveDetailTags to retrieve and display it.

For example, you have added a "trigger field" for the "article model" calledauthorCustom single-line text field:

{# 在文章详情页模板中 #}
<p>
    文章作者:{% archiveDetail with name="author" %}
</p>
{# 或者,如果已将当前文档详情赋值给archive变量,可以直接通过点语法访问 #}
<p>
    文章作者:{{ archive.author }}
</p>

This method is concise and clear, suitable for the scenario where you only need to display specific custom fields.

If you have added a 'reference field' for the 'product model' ascolorsDropdown selection (or multi-select) field, this field may have multiple values, or a simple image fieldproductImage:

{# 在产品详情页模板中 #}
<p>
    产品颜色:{{ product.colors }} {# 直接显示选中的值 #}
</p>
<p>
    产品图片:<img src="{{ product.productImage }}" alt="产品图片">
</p>

Please note:

  • If the custom field is multiline text and you want to support HTML format (for example, the backend editor provides rich text editing functionality), be sure to add it when displaying|safeFilter to prevent HTML code from being escaped and displayed directly:
    
    <div class="author-bio">
        <h4>作者简介</h4>
        {% archiveDetail with name="authorBio" %}{{ archive.authorBio|safe }}
    </div>
    

Method two: througharchiveParamsTag to iterate through all custom fields (for dynamic display or complex structures)

Sometimes you may want to iterate through all the custom fields under a content model, or the structure of a field is quite complex (such as an image group, multiple values of a checkbox). At this point,archiveParamsTags are very useful. They return an array containing all custom fields, which you can iterate over.

{# 在文章或产品详情页模板中 #}
<div class="custom-fields">
    <h3>详细参数</h3>
    {% archiveParams params %}
        {% for item in params %}
            {# 这里的item.Name是您在后台设置的“参数名”,item.Value是对应的值 #}
            <div>
                <span>{{ item.Name }}:</span>
                <span>
                    {% if item.Value is iterable %} {# 如果是数组或切片,例如多选框的值 #}
                        {% for sub_item in item.Value %}
                            {{ sub_item }} {% if not forloop.Last %},{% endif %}
                        {% endfor %}
                    {% else %}
                        {{ item.Value|safe }} {# 确保HTML内容不被转义 #}
                    {% endif %}
                </span>
            </div>
        {% endfor %}
    {% endarchiveParams %}
</div>

Hint:

  • archiveParamsTags default to getting the custom fields of the current page's document.
  • item.NameWill display the Chinese parameter name set in the background.
  • item.ValueWill display the field value filled in by the user.
  • By{% if item.Value is iterable %}Can determine whether the field value is an iterable type (such as multiple values in a multi-select field), and then display in the corresponding loop.
  • You can also determine this in the loop,item.Nameoritem.FieldNameCome to handle specific fields or

Related articles

How to configure and display the Tag label list in the article content of AnQiCMS?

In website content operation, Tag tags (also known as keyword tags) play a crucial role.It can not only help users find the content they are interested in quickly, but also effectively enhance the relevance and depth of the website's content, and is also very beneficial for search engine optimization (SEO).Our CMS is well-versed in this, providing comprehensive Tag label configuration and display features, allowing us to easily add tags to articles and flexibly display them on the website front-end.Next, we will learn in detail how to play with the article Tag tag in Anqi CMS.

2025-11-08

How to perform an in-site search in AnQi CMS based on keywords and display the search results?

In website operation, the in-site search function is a key link to improve user experience and help visitors quickly find the content they need.A high-efficiency search mechanism can not only improve user satisfaction but also extend the time users spend on the website.AnQiCMS (AnQiCMS) provides us with flexible and powerful tools to easily implement this feature. To implement in Anqi CMS, searching within the site based on keywords and displaying the results involves three core steps: **building the search form, creating the search results page template, and using template tags to display content.** Next

2025-11-08

How to obtain and display the previous/next document link on the template of AnQi CMS?

It is crucial to provide website visitors with a convenient navigation experience in the AnQiCMS content management system.After a user has finished reading a wonderful article or looking at a detailed product, they are usually eager to continue browsing related content.This link to the "previous" and "next" articles on the current document page will undoubtedly greatly enhance the user experience and extend their stay on the website.The AnQiCMS template system, with its flexible tag design, makes it very intuitive to retrieve and display these links on the document detail page.###

2025-11-08

How to implement pagination functionality and control the number of page numbers displayed on the list page of AnQi CMS?

When building a website list page, a good pagination experience is the key to improving user satisfaction and website performance.AnQi CMS understands this and provides intuitive and powerful tags to help us easily implement pagination on list pages, while flexibly controlling the display quantity of page numbers. ### Core Function Analysis: List Data and Pagination AnQi CMS achieves list pagination mainly by coordinating the use of two core tags: `archiveList` and `pagination`.

2025-11-08

How can AnQi CMS ensure website content security, prevent malicious scraping, and protect the display of picture copyrights?

In the era of the explosion of digital content, the security of website content, the prevention of malicious collection, and the protection of image copyrights have become core challenges that website operators cannot ignore.A stable and reliable content management system should be able to provide a set of effective solutions.AnQiCMS (AnQiCMS) as an enterprise-level content management system provides multi-dimensional functional support in this aspect, helping users effectively protect their digital assets.Firstly, in terms of the overall security of the website content, Anqi CMS provides a solid foundation of protection.It is developed based on Go language

2025-11-08

How to display the website logo and filing information in the AnQi CMS front-end template?

In website operation, Logo and filing information are not only the core of brand recognition, but also an important link for establishing user trust and complying with regulations.AnQi CMS took these key elements into consideration from the very beginning, providing intuitive settings and flexible template calling methods, allowing website operators to easily display this information on the front end.### Understanding AnqiCMS template mechanism Before delving into how to display the logo and filing information, it is very helpful to briefly understand the AnqiCMS frontend template mechanism.

2025-11-08

How does Anqi CMS implement the scheduled release of website content, so that it automatically displays at a specified time?

In content operations, efficiency and strategic thinking are the key to success.AnQiCMS (AnQiCMS) is well-versed in this field and offers a practical feature - scheduled content publishing, allowing website managers to accurately schedule the content release time, thus achieving automated operation and effectively enhancing the spread of content and website activity. ### Scheduling Posting: The Automation Tool for Content Operations Imagine that your website needs to publish industry news at a fixed time every morning, or plan a series of promotional articles in advance for specific holidays or marketing events. If relying on manual release by humans

2025-11-08

How to display the child category list of a specified category in Anqi CMS

The way website content is organized is crucial for user experience and information retrieval efficiency.A clear classification structure not only helps visitors quickly find the information they need, but also effectively enhances the professionalism and user retention rate of the website.In AnQiCMS (AnQiCMS), the flexible template tag system makes it very convenient to display the subcategory list of a specified category.### Core Tool: The Use of `categoryList` Tag To display the child category list of a specified category in Anqi CMS, we mainly use the `categoryList` tag

2025-11-08