Today, with the increasing refinement of content operation, the display method of website content is no longer just a simple title and text that can meet all needs.Whether it is to display product detailed parameters, registration information for events, or record the professional background of team members, we need a more flexible and structured content management approach.AnQiCMS (AnQi Content Management System) is exactly where it provides strong support, through its 'Custom Fields' feature, it helps us easily expand content display options, creating a highly personalized website experience.

Why do content display options need to be more flexible?

Imagine if we were to manage an e-commerce website, in addition to product names and descriptions, we would also need to display specific information such as color, size, material, inventory, origin, and a series of other details.If relying solely on piling up these data in the text, it not only leads to chaotic layout but also makes it difficult for users to quickly obtain the required information. It is also very inconvenient to manage on the backend and cannot be filtered or searched according to these properties.

AnQiCMS deeply understands this requirement, its 'flexible content model' design is exactly to solve the pain points of the solidified content structure of traditional CMS.It allows us to break out of the established frameworks of 'articles' and 'products', defining a set of exclusive, customizable fields for each type of content based on business logic, making the content more structured and providing endless possibilities for front-end display.

Content Model and Custom Fields in AnQiCMS

In AnQiCMS, custom fields exist依附于 the "content model".The system is preset with two commonly used models, 'Article Model' and 'Product Model', but its core highlight is that we can completely create new content models or extend existing models.

Log in to the "Content Management" section of the AnQiCMS backend, find the "Content Model" option, which is the core area for defining the content skeleton.We can see that each model has a series of basic attributes, such as model name, model table name (for database storage), URL alias, and so on.That which truly gives life to the content is the freely configurable 'custom fields' under each model.

How to Create and Configure Custom Fields

The process of creating a custom field is very intuitive. When editing or creating a new content model, we can add exclusive fields to the model.Each custom field needs to clearly define the following key properties:

  • Parameter name:This field shows the name displayed to the operator when editing content in the background management interface, such as 'Product Color', 'Event Date', 'Author Position', etc., and should be clear and easy to understand.
  • Call field:This is the unique identifier stored internally in the system and called in the template, usually it is recommended to use alphabets, likecolor/event_date/author_position. The template retrieves the corresponding data through this name.
  • Field type:AnQiCMS provides various field types to meet different data format requirements:
    • Single-line text:Suitable for brief text information, such as product models, one-line introductions.
    • Number:Ensure the input data is purely numeric, suitable for prices, inventory, quantities, etc.
    • Multi-line text:Suitable for long text descriptions, such as product features, author biographies, and even can be combined with Markdown editors to achieve rich text content.
    • Single choice, multiple choice, dropdown choice:These three types are very suitable for preset option content, such as product colors (red, green, blue), activity types (online, offline), or user permission levels, etc.We can pre-set the default values of the options, so the user just needs to check or select, which avoids errors and irregularities caused by manual input.
  • Mandatory?:Determine whether the user must fill in this field when publishing content to ensure the integrity of key information.
  • Default:Provide default values for the field to facilitate quick filling in by the user or as a fallback if not filled in.

By these flexible configuration options, we can tailor data structures for any type of content.For example, add fields such as 'house type', 'area', 'orientation', 'floor' and others to the 'real estate' model;Add fields such as "start time", "teacher", "tuition fee", "enrollment targets", etc. to the "Education Course" model.

Apply custom fields in content

Once the content model is defined and custom fields are added, these fields will be reflected on the backend document (article, product, etc.) editing page.They usually appear in the "Other Parameters" collapsible area, convenient for content editors to fill in.

When we are editing a "product" content, in addition to filling in the title and main description, we will also see input boxes for custom fields such as "product color", "product size", and so on.The editor only needs to fill in the corresponding data according to the actual situation.This structured input method not only makes content management more organized, but also greatly improves the efficiency and accuracy of content publishing.

Flexible display: How to call custom fields in the template

The value of the custom field is ultimately reflected in the flexible display on the front-end page.AnQiCMS uses a template engine syntax similar to Django, making it very convenient to call custom field data in templates.

For document (archive) or category (category) content, we can call custom fields in two main ways:

  1. Directly call specific fields:If you know the name of the custom field's 'calling field' (for exampleauthor/price), you can use it directly{% archiveDetail with name="author" %}or{{archive.author}}(IfarchiveIs the variable for the current content to get its value. This method is suitable for scenarios where it is necessary to display a specific custom field accurately. For example, displaying the author's name of a blog post:

    <p>作者:{% archiveDetail with name="author" %}</p>
    

    Or display the product price on the product detail page:

    <p>产品价格:¥ {% archiveDetail with name="price" %}</p>
    

    If the custom field is multiline text and you want it to parse Markdown to HTML, you can combinerenderFilter:

    <div>作者简介:{% archiveDetail authorIntro with name="author_intro" %}{{ authorIntro|render|safe }}</div>
    
  2. Loop through all custom fields:When the content model has multiple custom fields and you want to dynamically display all parameters in a list or table form,{% archiveParams %}The label is very useful. It returns an array object containing all custom field names and values, which we can iterate over in the template.This is very efficient for generating product parameter lists or member information cards, without manually listing each field.

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

    In this way, even if the background deletes or adds custom fields, the front-end page can automatically adapt without modifying the template code.

In addition, AnQiCMS's custom field capabilities extend to the additional properties of the guestbook and category, allowing for highly customized interaction and display of these parts.

In summary, AnQiCMS's custom field feature brings unprecedented flexibility to content operation.It enhances content from simple text blocks to structured data collections, enabling websites to carry richer and more personalized information, presented in a way that aligns with user habits and business needs.This ability not only improves the efficiency of content management, but more importantly, it empowers content, enabling it to reach users more accurately and dynamically, thus