As a professional who is deeply involved 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 content model custom field function, which is the foundation for our efficient content creation and management.Below, I will elaborate on how to add custom field types in 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
English CMS (EnglishCMS) provides great convenience for 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 for these models (or any custom models you 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 extend the traditional content structure to a more refined and industry-specific level.For example, for a real estate website, we may need to add fields such as 'apartment type', 'area', 'orientation', etc. to the 'housing' 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, while providing rich data support for 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 ManagementHere is listed all the available content models currently in the system, including the article model and product model built-in to AnQiCMS, as well as any custom models you may have already created.
Select the content model you want to add custom fields.Click the "Edit" operation corresponding to the model, 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 special area for 'Content Model Custom Fields'.
Configure custom fields of the content model
In the "Content Model Custom Fields" area, you can create new custom fields by clicking the "Add Field" button. Each custom field's settings include 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 content creators on the backend editing interface.For example, if you want to add a field for storing the article author, you can set its 'parameter name' to 'article author'.This name is intended to provide clear identification, convenient for content editors to understand and fill in.
Call Field (Database Field Name)
“auto” is the actual field name stored in the database for this custom field, as well as the identifier you use to call this field in the frontend template. Please make sure to use lowercase English letters for naming, for exampleauthororpriceEnsure its uniqueness and standardization. This name is an identifier at the program level and should not contain special characters or spaces.
field type
This is the core of the custom field feature, which defines the data type and input method of the field. AnQiCMS provides various field types to meet different content requirements:
- Single-line text (Text): Suitable for brief text inputs, such as headings, subheadings, short quotes, etc., usually limited to 250 characters.
- Number: Only input numbers, suitable for price, quantity, rating and other numeric data.
- Textarea: 适用于较长的文本内容,如详细描述、备注信息等,提供更大的输入区域。
- 单项选择(Radio): 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 Choice (Checkbox): 允许内容创作者从预设的多个选项中选择一个或多个。例如,产品特点(如“防水”、“防尘”、“快充”)[English]
- 下拉选择(Select): Provide a dropdown menu for content creators to select a value from a list. This is similar to a single selection, but it saves more interface space when there are many options.
For single-choice, multiple-choice, and dropdown selection, you need to enter one line of content for each option in the 'Default Value' field. AnQiCMS system will automatically parse each line as a separate option.
Is required
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 used automatically.For the selection fields (radio, checkbox, dropdown), the "Default Value" area is used to define all available options, with each option taking up a line.
Complete all field parameters configuration and click the Save button to apply your changes to the content model.
Utilize custom fields in the front-end template
Add custom fields 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 in the content model and the content creators have entered the corresponding data, you can access them in the template in the following ways:
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.您的调用字段名the form. For example,{{archive.author}}The author information of the document will be output.
Moreover, AnQiCMS also provides{% archiveDetail %}Use tags 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 to output the "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 %}
This way, you can present various personalized data entered in the background in an elegant and structured manner on your website, thus satisfying the diverse information needs of readers.
Summary
The content model custom field feature of AnQi CMS is an important manifestation of its flexibility.It allows website operators to break free from the constraints of traditional CMS, and precisely build the required data structure based on content characteristics and business logic.Whether it is to improve the efficiency of content publication or to provide richer and more accurate data for front-end display, custom fields play an indispensable role.Master and make good use of this feature, which will greatly enhance your website's content management capabilities and market competitiveness.
Common Questions and Answers (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.Enter the model editing page, and there will be a special "Content Model Custom Fields" 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 category data under this model will also be permanently deleted, and this data cannot be recovered.Therefore, please make sure to back up the data and confirm carefully before performing the delete operation.
3. Why doesn't my website front-end display after adding custom fields?Adding custom fields completes the definition and entry of the backend data structure. To display these fields on the website frontend, you will also need to modify the corresponding template files (such asdetail.htmlorlist.html),use the template tags provided by AnQiCMS (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.