How to add custom field types to AnQiCMS content model?

Calendar 👁️ 46

As a professional engaged in the content operation of AnQiCMS, I am well aware of the importance of the flexibility of the content model in meeting the diverse needs of readers.AnQiCMS provides powerful custom capabilities in content management, especially its custom field function of the content model, which is the foundation for our efficient content creation and management.Below, I will explain in detail how to add custom field types to the AnQiCMS content model to help you better build personalized content structures.


Add custom field type for AnQiCMS content model: Deeply customize your content structure

AnQiCMS (AnQiCMS) offers great convenience to website operators with its highly customizable content model.It not only provides preset models such as articles and products, but also allows us to add exclusive custom fields to these models (or any custom models we create) based on specific business needs.This feature is the key to personalized content display, optimized data management, and improved user experience.

In AnQiCMS, custom fields can help us expand the traditional content structure to a finer, more industry-specific level.For example, for a real estate website, we may need to add fields such as 'type', 'area', 'orientation', etc. to the 'house listing' content model;For an online course platform, we need fields such as "instructor", "course duration", "difficulty level", etc.By adding different types of custom fields, we can ensure the accuracy and completeness of the content, and provide rich data support for the front-end display.

Access the content model management interface

The first step in adding custom fields is to log in to the AnQiCMS backend management system.In the left navigation menu, you will find the "Content Management" module, click it, and then select the "Content Model".Here is listed all the content models available in the current system, including the article model and product model built into AnQiCMS, as well as any custom models you may have created.

Select the content model you want to add a custom field to. Click the 'Edit' operation corresponding to the model, and you will enter the detailed configuration page of the model.On this page, in addition to the basic information of the model (such as model name, URL alias, etc.), you will see a dedicated area for "content model custom fields".

Configure the custom fields of the content model

In the "Content Model Custom Field" area, you can create new custom fields by clicking the "Add Field" button. Each custom field setting includes several key parameters that determine the field's display format during backend entry and its storage method in the database:

Parameter name (display name)

This is the friendly name displayed to the content creator on the backend editing interface.For example, if you want to add a field to store the article author, you can set its "parameter name" to "article author".This name is intended to provide a clear identifier, making it convenient for content editors to understand and fill in.

Invoke field (database field name)

“Field name” is the actual field name stored in the database, as well as the identifier used to call this field in the front-end template. Please make sure to use lowercase English letters, such asauthororpriceEnsure its uniqueness and standardization. This name is a programmatic identifier and should not contain special characters or spaces.

Field type

This is the core of the custom field function, which defines the data type and input method of the field. AnQiCMS provides various field types to meet different content needs:

  • Single Line Text (Text): Suitable for short text inputs, such as headings, subheadings, brief quotations, etc., usually limited to 250 characters.
  • Number: Only numeric input is allowed, suitable for prices, quantities, ratings, and other numeric data.
  • Multiline Text (Textarea): Suitable for longer text content, such as detailed descriptions, remarks, etc., providing a larger input area.
  • Radio button: Allow content creators to select one from multiple preset options. For example, the 'recommendation level' of an article (such as 'Level 1 recommendation', 'Level 2 recommendation').
  • Multiple selection (Checkbox): Allow content creators to select one or more options from predefined ones. For example, product features (such as "waterproof", "dustproof", "fast charging").
  • Select dropdown (Select): Provide a dropdown menu for content creators to select a value from a list. This is similar to a single choice, but it saves more interface space when there are more options.

For single choice, multiple choice, and dropdown selection, you need to enter a line of content for each option in the 'default value' field. The AnQiCMS system will automatically parse each line as a separate option.

Mandatory?

This option determines whether the content creator must fill in this field when submitting content.If set to 'Yes', the system will perform a check before saving the content to ensure that this field is not empty.

Default value

You can set an initial value for the field. When content creators create new content in the background, if this field is not manually filled in, the default value set here will be automatically used.For selection fields (radio, checkbox, dropdown), the 'Default Value' area is used to define all available options, each option occupies a line.

After all field parameters are configured, please click the save button to apply your changes to the content model.

Utilize custom fields in the frontend template.

Adding a custom field is just the first step, and its ultimate purpose is to display these customized contents on the website front end.AnQiCMS provides flexible template tags, allowing you to easily call the data of these custom fields in the theme template.

When you add custom fields to the content model and the content creators have entered the corresponding data, you can retrieve them in the template in the following way:

If you know the name of the 'called field' of the custom field (for exampleauthor), you can directly access it on the document details page or in the document list byarchive.您的调用字段名in the form of. For example,{{archive.author}}The document's author information will be output.

In addition, AnQiCMS also provides{% archiveDetail %}Use the tag to get the value of a specific field, for example:{% archiveDetail with name="author" %}.

If you need to iterate over all custom fields of a document, you can use{% archiveParams %}Label. This label usually returns an array, you can loop through each field's "parameter name" and "value".This is very useful for building dynamic product parameter lists or information blocks.

{# 示例:在一个文档详情页调用单个自定义字段 #}
<div>文章作者:{% archiveDetail with name="author" %}</div>

{# 示例:循环输出文档的所有自定义字段 #}
{% archiveParams params %}
<div class="custom-fields-list">
    {% for item in params %}
    <div>
        <span>{{item.Name}}:</span> {# 显示参数名,如“文章作者” #}
        <span>{{item.Value}}</span> {# 显示字段值,如“张三” #}
    </div>
    {% endfor %}
</div>
{% endarchiveParams %}

In this way, you can display various personalized data entered in the background in an elegant and structured manner on your website, thereby satisfying readers' diverse information needs.

Summary

The content model custom field function of AnQi CMS is an important embodiment of its flexibility.It allows website operators to break free from the constraints of traditional CMS, accurately building the required data structure according to content characteristics and business logic.Whether it is to improve the efficiency of content publication or to provide richer and more accurate data for frontend display, custom fields play an indispensable role.Master and make good use of this feature, it will greatly enhance the content management capabilities and market competitiveness of your website.


Frequently Asked Questions (FAQ)

1. Where can I add custom fields to the content model?You can find and edit existing content models, or create new content models in the "Content Management" -> "Content Model" area of the AnQiCMS backend management interface.After entering the model editing page, there will be a special "Content Model Custom Field" area for you to add and configure fields.

2. What will happen if I delete a content model with custom fields?Deleting a content model is a very cautious operation. Once you delete a content model, all documents and categorization data under the model will also be permanently deleted, and this data is irrecoverable.Therefore, before performing the delete operation, please be sure to back up the data and confirm carefully.

3. Why doesn't my website front-end display after adding a custom field?Adding a custom field only completes the definition and entry of the background data structure. To display these fields on the website frontend, you also need to modify the corresponding template files (such asdetail.htmlorlist.html),use the AnQiCMS template tags (such as{% archiveDetail %}or{% archiveParams %}) to call and render the data of these custom fields. If the template is not called correctly, the data will not be displayed on the front end.

Related articles

What are the naming conventions for model table names when customizing AnQiCMS content models?

In the flexible and versatile content management ecosystem of AnQiCMS, custom content models are undoubtedly the key tools for website operators to achieve personalized content display and management.It enables us to create various types of content structures such as articles, products, and cases according to business needs, thus greatly enhancing the adaptability of the system.However, while enjoying this high degree of freedom, it is particularly important to follow the naming conventions set by the system, especially when defining model table names.As an experienced AnQiCMS operator, I am well aware of these seemingly minor regulations

2025-11-06

What data will be deleted when AnQiCMS content model is deleted?

Hello, as a fellow who deeply understands the operation of AnQiCMS, I fully understand your concern for the rigor of system operation.The content model is the core skeleton of AnQiCMS, defining the structure and type of content. Therefore, deleting a content model is not a trivial operation, as it will affect a large amount of related data.I will elaborate in detail on the data that will be deleted along with the AnQiCMS content model, as well as the potential indirect effects.

2025-11-06

What content models are built into AnQiCMS, can they be customized?

AnQiCMS (AnQiCMS) provides high flexibility and customization in content management, with its core being its powerful content model mechanism.As a website operator, I am well aware of the importance of content structure for information transmission and user experience, and AnQiCMS ensures this through its content model.In the AnQiCMS system, all content generation and management revolve around the content model.

2025-11-06

How long are documents in the AnQiCMS document recycling bin retained?

In the daily content operation of Anqi CMS, we deeply understand the importance of content assets.To ensure the security and recoverability of user content, the AnQiCMS system is built with a complete document recycling station mechanism.This feature ensures that after the content deletion operation, the document will not disappear permanently from the system immediately, but will enter a buffer area, providing valuable opportunities for operation personnel to regret and recover.

2025-11-06

What is the main difference between AnQiCMS document tags and document categories?

As an experienced security CMS website operator, I am well aware of the core status of content organization in website operation.In AnQiCMS, to manage and optimize content efficiently, we mainly rely on two powerful content organization tools: **Document Classification** and **Document Tags**.Although they are all intended to help us summarize and find content, there are significant differences in their design philosophy, functional focus, and actual application scenarios.The document classification plays a role in structuring content and serving as the main navigation skeleton in AnQiCMS.

2025-11-06

How to create and manage new document tags in AnQiCMS?

As an experienced CMS website operation person in the security industry, I am well aware of the importance of content tags in website content organization and search engine optimization (SEO).AnQi CMS provides a straightforward and flexible label creation and management mechanism, aimed at helping operators efficiently classify content, improving user experience, and optimizing the website's performance in search engines. ### Understanding Document Tags in AnQi CMS In AnQi CMS, document tags are a powerful content association tool.

2025-11-06

How to call document detail data (archiveDetail) in AnQiCMS template?

As an experienced CMS website operation personnel for a security company, I know that content is the core of the website, and how to efficiently and accurately display this content is the focus of our daily work.Today, we will delve into a crucial tag in the AnQiCMS template called `archiveDetail`, which allows us to flexibly call and display detailed document data.### Understanding the core function of the `archiveDetail` tag In AnQiCMS, whether it is articles, products, or other custom model content

2025-11-06

How to use AnQiCMS template tags to get a document list (archiveList) under specified conditions?

As an experienced security CMS website operator, I am well aware of the key role of efficient content management and accurate content presentation in the success of the website.In AnQiCMS, flexibly using template tags is an important way to achieve this goal.Today, we will delve into how to use the `archiveList` template tag to retrieve and display document lists according to specified conditions, thereby meeting diverse content display needs.

2025-11-06