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.