In website operation, the diversity and personalization of content are the key to attracting users and improving efficiency.AnQiCMS (AnQiCMS) understands this point and therefore provides powerful content model customization features, allowing us to flexibly adjust the display fields of content according to specific business needs.This article will take you deep into how to make full use of this powerful feature to create a content management experience that is more tailored to your business scenario.
Why do you need to customize the content model fields?
You may encounter such a situation: The default "article" or "product" model is universal, but in actual operation, many types of content require more unique properties to describe. For example:
- Product display website:In addition to the product name, price, and description, you may also need fields such as 'brand', 'model', 'color', 'warranty period', etc., so that users can better understand the product.
- Activity registration website:In addition to the activity title and content, you may also need fields such as 'event location', 'start time', 'end time', 'maximum number of participants', 'contact phone number', and so on.
- Team member introduction:In addition to name and profile, you may also need fields such as 'position', 'areas of expertise', 'contact email', 'start date', etc.
If only relying on the default field, this information may only be squeezed into the content details, which is not only unattractive but also不利于 management and screening.By customizing content model fields, you can create dedicated data structures for different types of content, greatly enhancing the system's adaptability to diverse content publishing needs and achieving personalized content display.
Create and manage custom fields in the AnQi CMS backend
AnQi CMS places content model management at the core, making field customization intuitive and powerful.
To start customizing, we first need to enter the Anqi CMS backend management interface, find the "Content Management" menu on the left side, and then click "Content Model".Here, you can see the built-in "article model" and "product model", as well as any other custom models you may have created.You can choose to modify an existing model, such as the "Product Model" to add more fields, or create a completely new model for your business.
When editing or creating a model, you will find that the most crucial area is the "custom fields of content model" apart from basic information such as model name, URL alias, etc.This is the place where we perform "custom magic". Click "Add field", and a new blank field will appear in front of you, waiting for your definition.
- Parameter name:This is the user-friendly name you see on the backend interface, such as "Product Brand", "Warranty Period". This name should be clear and easy for content editors to understand and fill in.
- Call field:This is a key English identifier used for technical calls, for example
brandorwarrantyPeriod. This field name is used for database storage and front-end template calls, so it is recommended to use lowercase letters and camel case, and to ensure that it is unique within the same model. - Field type:AnQi CMS provides various field types to meet different data input needs, each type has its characteristics:
- Single-line text:Suitable for short text input, such as product model, contact number.
- Number:Make sure to enter pure numbers, such as inventory quantities, prices.
- Multi-line text:Suitable for longer descriptive text, such as product features, precautions.
- Single choice:Allow content editors to select one from multiple predefined options, such as product colors (red, green, blue).
- Multiple selection:Allow multiple selections from predefined options, such as product features (waterproof, dustproof, night vision).
- Dropdown selection:Similar to single selection, but presented in a dropdown menu format, saving page space, such as "Shipping Method" (SF Express, YTO Express, STO Express). Select the content of the option, for example, if the single choice is 'Red, Green, Blue', then enter each option on a separate line in the 'Default Value' below.
- Mandatory?:Select based on business requirements. If a field is a required item when publishing content, check it so that the system can perform verification to avoid missing key information.
- Default:You can set a default value for the field. For selection fields, this is where you define all the options, one per line.
With these flexible configurations, you can easily build content structures that align with your business logic, making every content release more efficient and accurate.
Display custom fields on the front-end page
After defining the custom fields in the background, the next step is how to display this information on the website's frontend so that visitors can see it.The AnQi CMS template engine provides simple and powerful tags, making it easy to call custom fields.
Assuming we have added the "Brand" field (field name:brand), "Model" (field name:model)etc. custom fields.
When you want to display this information on the detail page of a product, you can usearchiveDetailtags. This tag is specifically used to retrieve detailed data from the current document, including our custom fields.
To display a specific custom field, such as the brand of a product, you can call it like this:
<div>产品品牌:{% archiveDetail with name="brand" %}</div>
HerenameThe parameter value is the 'call field' you set for the custom field in the background.
If you want to loop through all the custom fields of a document in an area, for example, displaying all product parameters on a product detail page, thenarchiveParamsTags will be very convenient. It can retrieve all the additional parameters of the current document configuration and return them as an array:
<div>
<h3>产品参数</h3>
{% archiveParams params %}
{% for item in params %}
<div>
<span>{{item.Name}}:</span>
<span>{{item.Value}}</span>
</div>
{% endfor %}
{% endarchiveParams %}
</div>
This code will traverse all the custom fields of the current product document and display them in the form of "parameter name: parameter value", which is very useful for displaying product specifications, real estate information, etc.
Further more, Anqi CMS also allows you to use custom fields to implement content filtering. ByarchiveFiltersLabel, you can create dynamic filter conditions based on custom fields, such as allowing users to filter lists based on "product color" or "event location"。This not only improves the user experience, but also greatly enhances the interactivity of the website content, can meet the needs of publishing various content structures, and greatly improves the adaptability of the system.
Case study: Add specific parameters to the product model
Let us take an e-commerce website as an example and add some commonly used and practical custom fields to the 'Product Model'.
- Enter the 'Content Model' management interface:Select "Product Model" to edit.
- Add "Brand" field:
- Parameter name:
产品品牌 - Call field:
brand - Field type:
单行文本 - Mandatory?:
是
- Parameter name:
- Add "Model" field:
- Parameter name:
产品型号 - Call field:
model - Field type:
单行文本 - Mandatory?:
是
- Parameter name:
- Add "Color" field:
- Parameter name:
可选颜色 - Call field:
colors - Field type:
多项选择 - Default values (one per line):
红色/蓝色/绿色/黑色
- Parameter name:
- Add the "Warranty Period" field:
- Parameter name:
保修期限 - Call field:
warrantyPeriod - Field type:
下拉选择 - Default values (one per line):
一年/两年/三年/终身保修
- Parameter name:
After saving these changes, when you go to publish or edit a product, you will see the newly added fields in the "Other Parameters" area. Content editors can clearly fill in product brand, model, and other information.In the front-end template, simply call the corresponding tags, and these rich product attributes can be displayed to the user in a structured way, greatly enhancing the readability and practicality of the content.
Conclusion
The content model customization feature of AnQi CMS is a powerful tool to enhance the efficiency and flexibility of website content management.It elevates the structuring of content to a new height, allowing you to not only publish diverse content but also display them in the most business-friendly way possible.From simple articles to complex e-commerce products, AnQi CMS can provide strong support to help you efficiently carry out content marketing and user interaction.Now, go explore and customize your exclusive content model!
Frequently Asked Questions (FAQ)
Q1: I added a custom field in the backend, why isn't it showing up on the front-end page?
A1:Adding custom fields in the background just defines the data structure. To display these fields on the front-end page, you need to call them in the corresponding template files. You can usearchiveDetailTag to get the value of a single custom field, or usearchiveParamsTag to iterate and display all custom fields. Please check your template file, for example{模型table}/detail.htmlorpage/detail.htmlDoes it include the corresponding call code?
Q2: Can custom fields be used as filtering conditions for content lists?
A2:Yes, Anqi CMS supports using custom fields as list filtering criteria. You need to configure the specific field as filterable in the background content model. Then, in the template, combinearchiveFiltersTags andarchiveListLabels, by dynamically passing filtering values through URL parameters, you can achieve content filtering based on custom fields. This helps users find the content they are interested in more quickly.
Q3: If I need to use the value of a custom field as an image address or link, what should I do?
A3:When the custom field type is 'Single Line Text', you can directly enter the image URL or link address in the field content. When calling the front-end template, if it is an image address, you can directly use `{% archiveDetail with