Good, as an experienced website operation expert, I am more than happy to deeply analyze the powerful functions and practical operations of the custom fields in AnQiCMS.


Create custom fields for different content models in AnQiCMS: unlock the powerful engine for personalized content

In the era where content is king, the diversity and personalization of website content are the key to attracting and retaining users.An excellent content management system (CMS) should never limit you to a fixed content structure.Create custom fields for different content models (such as articles, products)Thus, make your website content management more agile and unique.

Understanding the content model: the foundation of all personalization.

In AnQiCMS, all the content on your website is organized around the 'content model'.The system is built-in with two core models, "Article Model" and "Product Model", which define the basic information structure for articles and products respectively.However, the business requirements in reality are far more complex.An industry analysis article may require 'analyst name', 'source of report'; and an e-commerce product may need 'color options', 'size details', 'material description', etc., in addition to the conventional 'price', 'stock'.Now, custom fields are born.

The custom field allows you to add any data items you consider necessary to the existing content model, in order to accurately reflect the unique attributes of your content.This not only greatly enhances the flexibility of content management, but also provides more possibilities for front-end display and SEO optimization.

How to create custom fields in AnQiCMS?

The process of creating custom fields is intuitive and efficient, let's go through it step by step:

First, log in to the AnQiCMS backend management interface, find the "Content ManagementHere, you will see the list of all content models on the website, including built-in 'Article Model', 'Product Model', and any other custom models you may have created.

Select the content model you want to edit to add custom fields.For example, if you want to add more attributes to e-commerce products, click on 'Product Model' to enter its details page.Custom fields of the content modelarea. This is where we work our magic.

Click the "Add Field" button, and a brand new field configuration form will appear before you. Here, you need to fill in some key information:

  1. Parameter name:This is the display name of the field, which is convenient for you to identify and operate in the background, such as “Author Name”, “Product Material”, “Release Date”, and so on.Suggest using clear and understandable Chinese names.

  2. Field call:English lettersAs a field name, do not include spaces. For example, "Author Name" can be set asauthorName,“Product Material”can be set asmaterial。Remember this name, it will be the 'key' you use to retrieve data in the template.

  3. Field Type:AnQiCMS provides various field types to meet different data storage needs.

    • Single-line text:Applicable for storing brief string information, such as the "author name" of an article or the "brand" of a product.
    • Numbers:专为数值而设计,像产品的“价格”或“库存量”就非常合适。
    • Multi-line text:As the name implies, it is used to input longer text content, such as a product's 'detailed features description' or an article's 'additional summary'.
    • Single choice, multiple choice, dropdown selection:These three types are suitable for providing preset options for user selection.For example, set the 'Color' option for the product (red, blue, green), and you can choose whether it is a single selection or multiple selection.When selecting these types, you need to enter an option per line in the "Default Values" area below, and the system will automatically parse it as an optional item.
  4. Mandatory:Select according to business requirements. If this field is a required item when publishing content, please check this option. The system will verify it when submitted.

  5. Default value:If the field has a common value when the content is created, it can be preset here. For selection fields, this is used to define all optional items.

Configure the field and click "OK" to save. You can add any number of custom fields for the same content model as needed.

Use custom fields when publishing content

When you have completed the creation of a custom field and associated it with a content model, these fields will dynamically appear when you publish or edit content that belongs to that content model.For example, when you add an "article" or "product" under "Content Management", you will find the custom fields you just defined in the "Other Parameters" collapse box in the form.

It is worth mentioning that AnQiCMS's dynamic adaptability is very intelligent.If you define 'author name' for the 'article model' and 'material' for the 'product model', then only the 'author name' field will be displayed when publishing articles; while the 'material' field will be displayed when publishing products.This design for dynamically switching fields based on content models greatly simplifies backend operations and avoids unnecessary confusion.

Display custom fields in the front-end template

The value of custom fields ultimately manifests in front-end display.AnQiCMS provides flexible template tags, allowing you to easily display these custom data on the website page.The name of the "call field" you set when creating a field, which is the key to your interaction with the template.

Suppose you have added a custom field namedmateriala custom field named "product material" (field called):

Method one: Direct accessarchiveObject Call (for known field names)

You can directly access it through the template on the product detail page,archive(or the custom document variable name you have set) object to access this field:

<!-- 产品材质 -->
<div>
    <span>产品材质:</span>
    <span>{{ archive.material }}</span>
</div>

Method two: usearchiveDetailLabel call (for retrieving specific fields)

It can also be usedarchiveDetailTo retrieve the value of a specific custom field, use the label:

<!-- 产品材质 -->
<div>
    <span>产品材质:</span>
    {% archiveDetail productMaterial with name="material" %}
    <span>{{ productMaterial }}</span>
</div>

Method three: usearchiveParamsLabel traverses all custom fields (suitable for dynamic display)

If you want to dynamically display all custom fields and their values under a certain content model (for example, generating a 'Product Parameters' table on a product details page),archiveParamsThe label will be your**choice.

<!-- 产品参数列表 -->
<div class="product-params">
    <h3>产品参数</h3>
    <ul>
        {% archiveParams params %}
            {% for item in params %}
                <li>
                    <span>{{ item.Name }}:</span>
                    <span>{{ item.Value }}</span>
                </li>
            {% endfor %}
        {% endarchiveParams %}
    </ul>
</div>

Through these methods, you can flexibly render custom field data to the page according to your front-end design needs, whether it's simple text display, complex option listing, or rich media content like images, links, etc.

Summary

Master and make good use of AnQiCMS custom fields, you will be able to build a truly tailored, dynamic website to meet your business needs, giving wings to your content marketing and user growth.


Common Questions (FAQ)

1. If I call a custom field in the template and I spell the field name wrong (for examplearchive.myCustomField) what will happen?答:If the field name is spelled incorrectly or does not match the "Calling Field" set in the background, the template will display as blank or report an error when parsing (depending on your template