How to utilize the flexible content model of Anqi CMS to define display fields for different types of content?

Calendar 👁️ 59

In today's increasingly rich and diverse digital content, the flexibility of a website content management system (CMS) is crucial.AnQiCMS (AnQiCMS) understands this, one of its core advantages is that it provides a powerful "flexible content model" function, allowing users to customize dedicated display fields for various content according to different business needs.This greatly enhances the adaptability of the website, making content operations more efficient and personalized.

Imagine that your website may not only publish ordinary articles, but also display product information, as well as various types of content such as event registration, case sharing, and more.If all this content shares a fixed set of fields, then the product price, inventory information will not be reflected in the article, and the start time, location of the event cannot be displayed on the product page either.The flexible content model of AnQi CMS is designed to solve this pain point, allowing you to build unique 'skeletons' for each content type like building blocks.

Flexible content model: Customized for your content type

In AnQi CMS, the 'content model' can be understood as a blueprint for data structures of different content types.The system is pre-installed with the "Article Model" and "Product Model" as basic models, each with a set of commonly used fields.If these default fields are not enough to meet your specific needs, or if you need to create a completely new content type, AnQi CMS provides great flexibility to modify existing models or create new custom models.

To start customizing your content model, simply log in to the backend, navigate to the "Content Management" module, and then select the "Content Model" management.Here, you can edit existing models or create new ones.

Core operation: Define the display fields of the content model

Custom fields are the core of flexible content models and the key steps to add exclusive properties for specific content types. In the content model editing interface, you can add various custom fields to your model:

  1. Parameter name:This is the field name displayed to the editor during backend content editing, it should be friendly and easy to understand, for example 'article author', 'product brand', 'event location', and so on.
  2. Call field:This is the actual variable name used when calling this field in the front-end template. It is usually written in lowercase letters, and it is recommended to use camelCase naming (for examplearticleAuthororproductBrand), so that it can be accessed through the template.{{archive.productBrand}}or{{item.articleAuthor}}You can get its value. This field name is the key bridge connecting backend data with frontend display.
  3. Field type:AnQi CMS provides various field types to meet the storage and display needs of different data:
    • Single-line text:Suitable for short text information, such as 'product model', 'event theme'.
    • Number:Only numbers are allowed, suitable for "product price
    • Multi-line text:Provide rich text editor functionality, which is very suitable for storing long descriptive content, such as "Product Details|safeA filter to parse HTML and ensure the style is correct.
    • Single choice, multiple choice, dropdown choice:These types allow you to preset a series of options, where users can only choose from them (single select, dropdown) or select multiple options (multi-select).This is very useful for standardizing content attributes, such as "product color", "service type", "region selection".When defining such fields, you can list all optional items in the 'default value', one per line.
  4. Mandatory?:You can specify whether a field is required. This helps ensure the completeness of the content and avoid missing key information when publishing.
  5. Default:Setting a default value for a field can reduce the workload of content editing. For example, setting the default value "Original" for the "Article Source" field can save the trouble of manual input each time.

In addition to custom fields, there are some other important configurations in the content model settings, such as "Model Name" (displayed in the backend breadcrumb navigation), "URL Alias" (used for static URL rules, helpful for SEO), and "Title Name" (custom prompt text for the title field when publishing content).These settings collectively constitute the "skeleton" of the content, ensuring the standardization and flexibility of backend management and frontend display.

Flexibly call custom fields in the front-end template

How do you display these fields on the front-end page after defining the content model and custom fields? Anqi CMS provides intuitive tags to access this data.

  • Call by variable name:If you know the name of the custom field's 'call field' name, you can use it directly in the template{{archive.您的调用字段名}}to retrieve and display its content. For example, a field namedproductBrandThe field is called, and it can be directly used in the product detail page template.{{archive.productBrand}}To display brand information.
  • Loop through all custom fields:For those who are unsure about what custom fields there are, or want to dynamically generate a product parameter list, you can use{% archiveParams params %}A tag to iterate over all custom fields of the current content model. This tag will return an array containing the names of the fieldsName) and the values of the fields, and you can useValue) to access them.forDisplay in a loop.

Example code snippet:Assuming your product model has a custom field, the field name isproductMaterial(Product material), and stores rich text content.

{# 在产品详情页模板中,直接调用产品材质字段 #}
<div>
    <span>产品材质:</span>
    {# 注意:如果内容是富文本,需要使用 |safe 过滤器来解析HTML #}
    <span>{{ archive.productMaterial|safe }}</span>
</div>

{# 另一个场景:循环展示所有自定义参数 #}
<h3>产品参数</h3>
<ul>
    {% archiveParams params %}
    {% for item in params %}
        {# 排除一些不希望在公共参数区显示的字段,例如产品图片组可能不需要在这里显示 #}
        {% if item.FieldName != 'productImages' %}
            <li>
                <span>{{item.Name}}:</span>
                <span>{{item.Value}}</span>
            </li>
        {% endif %}
    {% endfor %}
    {% endarchiveParams %}
</ul>

In this way, you can flexibly define content fields in the background according to business requirements, and accurately control the display of these fields on the front-end page, thereby achieving truly personalized content presentation.

Actual application scenarios:

  • Article detail page:In addition to the title and content, you can also add custom fields such as "article author", "article source", "publishing organization", and elegantly display them in the template.
  • Product display page:Add 'Brand', 'Color', 'Size', 'Material', 'Production Date', 'Expiry Date', and other fields to each product so that customers can see at a glance.
  • Event page:Add "Event Time", "Event Location", "Registration Deadline", "Registration Fee", "Speaker", and other dedicated fields for easy viewing and registration.

The flexible content model of Anqi CMS, as if it injects powerful malleability into the content of your website, allowing you to break free from the constraints of traditional CMS, truly realizing the vision of "content-driven, display as you wish".


Frequently Asked Questions (FAQ)

Q1: What is the difference between 'parameter name' and 'invocation field'? Which one should I use in the template?A1: 'Parameter name' is the more descriptive field name you see when editing content in the Anqi CMS backend, which is convenient for managers to understand.And 'field name used to call' is the variable name you actually use in the front-end template to get the data of the field.In the template, you always need to use 'field call' to retrieve data, for example{{archive.yourCallingField}}.

Q2: If I enter rich text content (such as bold, links) for a 'Multiline Text' type custom field, the HTML code will be displayed directly in the template. How can I make it render as styled text?A2: When your custom field stores HTML formatted rich text content, it needs to be used in the template when called|safeFilter. For example,{{archive.yourMultiLineTextField|safe}}. This filter tells the template engine that this content is safe HTML code, which does not need to be escaped and can be rendered directly.

Q3: Can I set different URL structures for different content models? For example, for articles using/article/id.html, products using/product/name.html?A3: Yes, Anqi CMS supports flexible pseudo-static rules.You can set independent URL structures for different content models (such as article models, product models) in the "Function Management" -> "Static Rule" section of the background, including using model IDs, URL aliases, and other custom variables.This helps with SEO and also makes the website URL more readable.

Related articles

What ways does Anqi CMS support to adjust the overall content display mode of the website (adaptive, code adaptation, PC+mobile independent site)?

AnQi CMS: Three Flexible Options for Customizing Website Content Display Mode How to present the effect of website content on different devices is an important issue that every webmaster needs to consider when building and operating a website.Anqi CMS understands this point and therefore provides a variety of flexible content display modes, allowing you to choose the most suitable way to build your website according to your actual needs.No matter if you are pursuing a simple and efficient experience or need an ultimate customization experience, AnQi CMS can provide strong support.Next, we will delve into the three website content display modes supported by Anqi CMS

2025-11-08

How to filter and display content on the article list page based on specific conditions (such as recommended attributes)?

In our website content operation, the article list page often plays an important display role.We do not want to simply arrange the content mechanically according to the time of publication, but we hope to be able to flexibly filter and display articles based on certain conditions, such as the importance of the content, popularity, or whether it is recommended.AnQiCMS (AnQiCMS) was designed with these needs in mind from the outset, providing us with a simple yet powerful content filtering mechanism.

2025-11-08

How to format a timestamp into a readable format

## Let Time Speak: How to Format Timestamps into Readable Dates in Anqi CMS When operating a website, the timeliness of content is often a point of great concern for users.Whether it is the publication time of the article, the update time of product information, or the specific moment of user comments, clear and intuitive dates and times can greatly improve the user experience, and even have a positive impact on search engine optimization (SEO).However, in the backend of the content management system, we sometimes see time presented as a long string of numbers, like `1609470335`.

2025-11-08

How to safely output user-generated content in AnQiCMS templates to prevent XSS attacks from affecting the display of the page?

The website content operation is in progress, user-generated content (UGC) is undoubtedly a valuable resource for enhancing the vitality and interactivity of the website.Whether it is comments, messages, forum posts, or articles edited with a rich text editor, all of these greatly enrich the information ecology of the website.However, potential security risks come with UGC, the most common and severe of which is cross-site scripting (XSS) attacks.If not prevented, malicious script code may be executed in the user's browser, stealing user data, and tampering with the page

2025-11-08

How does AnQi CMS ensure the correct switching and display of different language content on a multilingual website?

Today, with the deepening of globalization, website content can reach different language user groups and has become a key factor for enterprises to expand the market and enhance brand influence.For users who operate multilingual websites, one of the most concerning issues is how to ensure the correct switching and display of different language content?AnQiCMS (AnQiCMS) provides a clear and efficient solution in this regard, let's take a look at how it is implemented.

2025-11-08

How to optimize the URL structure through pseudo-static rules to improve the display effect of content in search engines?

When operating a website, we all hope that our content can be seen by more users, and search engines are undoubtedly an important source of traffic.To perform well in search engines, in addition to the quality of the content itself, the structure of the website's URL (website address) also plays a crucial role.A clear and friendly URL, not only makes it easier for users to understand and remember, but also helps search engines better crawl and understand our content.And the static rules, which are an effective means to optimize URL structure, AnQiCMS (AnQiCMS) provides very convenient functions in this aspect.###

2025-11-08

How does the AnQi CMS scheduled publication function control content to be displayed to the public after a specified time?

In today's world where digital content is increasingly abundant, an efficient and accurate content publishing strategy is crucial for any website operator.AnQiCMS (AnQiCMS) understands this and has specially provided you with a powerful timed publishing function, allowing you to precisely control when each piece of content is displayed to the public after the specified time, thus achieving more flexible and strategic content operation.

2025-11-08

How to configure content settings to automatically handle remote image downloads, external link filtering, and Webp image format conversion to optimize display performance?

The efficiency of content presentation and user experience is one of the key factors for success.In the daily operation, the speed of image loading, the standardization of links, and other details all directly affect the visitors' stay and the search engine's friendliness.AnQiCMS is well-versed in this, providing a variety of practical functions in content settings to help us easily cope with these challenges and optimize the display performance of the website. ### Automatically Handle Remote Image Downloads: Make Content More Stable and Load Faster When editing website content, we sometimes refer to images from other websites.

2025-11-08