In website operation, content diversity and personalization are key to attracting users and improving efficiency.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 guide you to deeply understand how to make the most of this powerful feature, creating a content management experience tailored to your business scenarios.

Why do you need to customize the content model fields?

You may encounter such a situation: The default 'article' or 'product' model may be general, but in actual operation, many specific types of content require more unique attributes 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 get a more detailed understanding of the product.
  • Event registration website:In addition to the activity title and content, you may also need fields such as 'activity location', 'start time', 'end time', 'maximum number of participants', and 'contact phone number'.
  • Team member introduction:In addition to name and introduction, you may also need fields such as 'position', 'area of expertise', 'contact email', and 'date of joining'.

If relying solely on default fields, this information may only be crammed into the content details, which is neither aesthetically pleasing nor conducive to management and filtering.By customizing content model fields, you can create dedicated data structures for different types of content, significantly 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 ManagementHere, 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 model that is entirely unique to your business.

When editing or creating a model, you will find that the most core area is 'Content Model Custom Fields', besides the basic information such as model name, URL alias, etc.This is where we perform the "custom magic".Click "Add Field", and a new blank field will appear in front of you, waiting for your definition.

  1. 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 to understand, so that content editors can fill it out easily.
  2. Field call:This is a critical, English identifier used for technical calls, such asbrandorwarrantyPeriodThis field name is used in both database storage and front-end template calls, so it is recommended to use lowercase letters and camel case naming, and to ensure it is unique within the same model.
  3. Field Type:The AnQi CMS provides various field types to meet different data input requirements, each type has its characteristics:
    • Single-line text:Applicable for short text inputs, such as product models, contact numbers.
    • Numbers:Make sure to enter pure numbers, such as inventory quantities, prices.
    • Multi-line text:Suitable for longer descriptive texts, such as product features and precautions.
    • Single choice:Allow content editors to select one from a predefined set of options, such as product colors (red, green, blue).
    • Multiple selection:Allow multiple selections from a predefined set of 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 item content, for example, in the 'Red, Green, Blue' of a single choice, just fill in each option on each line in the 'Default Value' below.
  4. Mandatory:Select based on business requirements. If a field is a required entry when publishing content, checking it will trigger system verification to avoid missing key information.
  5. Default value:You can set a default value for the field. For selection type fields, this is where you define all the options, one per line.

Through 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 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 template engine of Anqi CMS provides concise and powerful tags, making it easy to call custom fields.

Assuming we have added the 'Brand' (field name: brand), 'Model' (field name: model) and other custom fields.

When you want to display this information on the product detail page, you can usearchiveDetailtags. This tag is specifically used to retrieve detailed data of 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>

Here are thenameThe parameter value is the "calling field" you set for the custom field in the backend.

If you wish to cyclically display all custom fields of a document within a region, 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 practical for displaying product specifications, real estate information, etc.

Further more, AnQi CMS also allows you to use custom fields to implement content filtering. ByarchiveFiltersTags, you can create dynamic filtering conditions based on custom fields, such as allowing users to filter lists by 'product color' or 'event location'.This not only improves the user experience, but also greatly enhances the interactivity of the website content, able to meet the needs of publishing various content structures, and significantly improves the adaptability of the system.

Practical Case: Add specific parameters to product models

Let us take an e-commerce website as an example and add some commonly used and practical custom fields for the "product model".

  1. Enter the "content model" management interface:Select 'Product Model' to edit.
  2. Add 'Brand' field:
    • Parameter name:产品品牌
    • Field call:brand
    • Field Type:单行文本
    • Mandatory:
  3. Add 'Model' field:
    • Parameter name:产品型号
    • Field call:model
    • Field Type:单行文本
    • Mandatory:
  4. Add 'Color' field:
    • Parameter name:可选颜色
    • Field call:colors
    • Field Type:多项选择
    • Default values (one per line):红色/蓝色/绿色/黑色
  5. Add the "Warranty Period" field:
    • Parameter name:保修期限
    • Field call:warrantyPeriod
    • Field Type:下拉选择
    • Default values (one per line):一年/两年/三年/终身保修

After saving these modifications, when you go to publish or edit a product, you will see these newly added fields in the "Other Parameters" section. Content editors can clearly fill in product brand, model, and other information.And in the front-end template, simply call the corresponding tags, and these rich product attributes can be displayed to users in a structured manner, greatly enhancing the readability and practicality of the content.

Concluding remarks

The content model custom feature of Anqi CMS is a powerful tool to enhance the efficiency and flexibility of website content management.It raises the structure of content to a new height, allowing you not only to publish diverse content but also to display them in the most business-friendly way.From simple articles to complex e-commerce products, Anqi CMS can provide strong support, helping you efficiently carry out content marketing and user interaction.Now, go explore and customize your exclusive content model!

Common Questions (FAQ)

Q1: I added a custom field in the backend, why isn't it showing up on the frontend page?

A1:Adding custom fields in the background only 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 usearchiveDetailUse the [field] tag to get the value of a single custom field, or usearchiveParamsthe [fields] tag to iterate and display all custom fields. Please check your template file (such as{模型table}/detail.htmlorpage/detail.htmlDoes it contain the corresponding call code?

Q2: Can custom fields be used as filtering criteria for content lists?

A2:Yes, AnQi CMS supports using custom fields as list filter conditions. You need to configure the specific field as filterable in the content model on the backend. Then, in the template, combinearchiveFiltersTags andarchiveListTags, pass the filter value through URL parameters, and you can realize the content filtering function based on custom fields. This helps users find the content they are interested in faster.

Q3: How should I handle if I need to use the value of a custom field as an image address or link?

A3:When the custom field type is set to "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