In today's increasingly rich and diverse digital content, the flexibility of a website content management system (CMS) is crucial.AnQiCMS (AnQiCMS) understands this, one of its core advantages is that it provides a powerful "flexible content model" function, allowing users to customize dedicated display fields for various content according to different business needs.This greatly enhances the adaptability of the website, making content operations more efficient and personalized.

Imagine that your website may not only publish ordinary articles, but also display product information, as well as various types of content such as event registration, case sharing, and more.If all this content shares a fixed set of fields, then the product price, inventory information will not be reflected in the article, and the start time, location of the event cannot be displayed on the product page either.The flexible content model of AnQi CMS is designed to solve this pain point, allowing you to build unique 'skeletons' for each content type like building blocks.

Flexible content model: Customized for your content type

In AnQi CMS, the 'content model' can be understood as a blueprint for data structures of different content types.The system is pre-installed with the "Article Model" and "Product Model" as basic models, each with a set of commonly used fields.If these default fields are not enough to meet your specific needs, or if you need to create a completely new content type, AnQi CMS provides great flexibility to modify existing models or create new custom models.

To start customizing your content model, simply log in to the backend, navigate to the "Content Management" module, and then select the "Content Model" management.Here, you can edit existing models or create new ones.

Core operation: Define the display fields of the content model

Custom fields are the core of flexible content models and the key steps to add exclusive properties for specific content types. In the content model editing interface, you can add various custom fields to your model:

  1. Parameter name:This is the field name displayed to the editor during backend content editing, it should be friendly and easy to understand, for example 'article author', 'product brand', 'event location', and so on.
  2. Call field:This is the actual variable name used when calling this field in the front-end template. It is usually written in lowercase letters, and it is recommended to use camelCase naming (for examplearticleAuthororproductBrand), so that it can be accessed through the template.{{archive.productBrand}}or{{item.articleAuthor}}You can get its value. This field name is the key bridge connecting backend data with frontend display.
  3. Field type:AnQi CMS provides various field types to meet the storage and display needs of different data:
    • Single-line text:Suitable for short text information, such as 'product model', 'event theme'.
    • Number:Only numbers are allowed, suitable for "product price
    • Multi-line text:Provide rich text editor functionality, which is very suitable for storing long descriptive content, such as "Product Details|safeA filter to parse HTML and ensure the style is correct.
    • Single choice, multiple choice, dropdown choice:These types allow you to preset a series of options, where users can only choose from them (single select, dropdown) or select multiple options (multi-select).This is very useful for standardizing content attributes, such as "product color", "service type", "region selection".When defining such fields, you can list all optional items in the 'default value', one per line.
  4. Mandatory?:You can specify whether a field is required. This helps ensure the completeness of the content and avoid missing key information when publishing.
  5. Default:Setting a default value for a field can reduce the workload of content editing. For example, setting the default value "Original" for the "Article Source" field can save the trouble of manual input each time.

In addition to custom fields, there are some other important configurations in the content model settings, such as "Model Name" (displayed in the backend breadcrumb navigation), "URL Alias" (used for static URL rules, helpful for SEO), and "Title Name" (custom prompt text for the title field when publishing content).These settings collectively constitute the "skeleton" of the content, ensuring the standardization and flexibility of backend management and frontend display.

Flexibly call custom fields in the front-end template

How do you display these fields on the front-end page after defining the content model and custom fields? Anqi CMS provides intuitive tags to access this data.

  • Call by variable name:If you know the name of the custom field's 'call field' name, you can use it directly in the template{{archive.您的调用字段名}}to retrieve and display its content. For example, a field namedproductBrandThe field is called, and it can be directly used in the product detail page template.{{archive.productBrand}}To display brand information.
  • Loop through all custom fields:For those who are unsure about what custom fields there are, or want to dynamically generate a product parameter list, you can use{% archiveParams params %}A tag to iterate over all custom fields of the current content model. This tag will return an array containing the names of the fieldsName) and the values of the fields, and you can useValue) to access them.forDisplay in a loop.

Example code snippet:Assuming your product model has a custom field, the field name isproductMaterial(Product material), and stores rich text content.

{# 在产品详情页模板中,直接调用产品材质字段 #}
<div>
    <span>产品材质:</span>
    {# 注意:如果内容是富文本,需要使用 |safe 过滤器来解析HTML #}
    <span>{{ archive.productMaterial|safe }}</span>
</div>

{# 另一个场景:循环展示所有自定义参数 #}
<h3>产品参数</h3>
<ul>
    {% archiveParams params %}
    {% for item in params %}
        {# 排除一些不希望在公共参数区显示的字段,例如产品图片组可能不需要在这里显示 #}
        {% if item.FieldName != 'productImages' %}
            <li>
                <span>{{item.Name}}:</span>
                <span>{{item.Value}}</span>
            </li>
        {% endif %}
    {% endfor %}
    {% endarchiveParams %}
</ul>

In this way, you can flexibly define content fields in the background according to business requirements, and accurately control the display of these fields on the front-end page, thereby achieving truly personalized content presentation.

Actual application scenarios:

  • Article detail page:In addition to the title and content, you can also add custom fields such as "article author", "article source", "publishing organization", and elegantly display them in the template.
  • Product display page:Add 'Brand', 'Color', 'Size', 'Material', 'Production Date', 'Expiry Date', and other fields to each product so that customers can see at a glance.
  • Event page:Add "Event Time", "Event Location", "Registration Deadline", "Registration Fee", "Speaker", and other dedicated fields for easy viewing and registration.

The flexible content model of Anqi CMS, as if it injects powerful malleability into the content of your website, allowing you to break free from the constraints of traditional CMS, truly realizing the vision of "content-driven, display as you wish".


Frequently Asked Questions (FAQ)

Q1: What is the difference between 'parameter name' and 'invocation field'? Which one should I use in the template?{{archive.yourCallingField}}.

Q2: If I enter rich text content (such as bold, links) for a 'Multiline Text' type custom field, the HTML code will be displayed directly in the template. How can I make it render as styled text?A2: When your custom field stores HTML formatted rich text content, it needs to be used in the template when called|safeFilter. For example,{{archive.yourMultiLineTextField|safe}}. This filter tells the template engine that this content is safe HTML code, which does not need to be escaped and can be rendered directly.

Q3: Can I set different URL structures for different content models? For example, for articles using/article/id.html, products using/product/name.html?A3: Yes, Anqi CMS supports flexible pseudo-static rules.You can set independent URL structures for different content models (such as article models, product models) in the "Function Management" -> "Static Rule" section of the background, including using model IDs, URL aliases, and other custom variables.This helps with SEO and also makes the website URL more readable.