安企CMS as an efficient and customizable enterprise-level content management system, one of its core highlights is the "flexible content model".This feature greatly expands the management boundaries of website content, allowing us to create various unique content structures according to actual business needs.And among them, custom fields (or custom parameters) play a crucial role, making our website content no longer limited to traditional article titles, content, and summaries, but capable of carrying more personalized information and ultimately displaying flexibly on the front-end page.

Flexible content model and the foundation of custom fields

Imagine, a traditional CMS might only provide two fixed content types such as 'articles' or 'products'.If we need to publish an "event" or a "case", which includes the start time, location, number of registrants, the customer name of the case, industry background, and other unique information, these fixed content types seem to be inadequate.

Practical steps for creating and managing custom fields on the backend

In the AnQi CMS backend, managing custom fields is an intuitive and powerful process.English translation: Generally, we need to enter the 'Content Model' settings from the 'Content Management' menu.Here, you will see the built-in "article model" and "product model", and you can also create new content models.

Whether it is editing an existing model or creating a new model, the core steps are to enter the model's details page, find the 'Content Model Custom Fields' area. Here, we can add the required fields to the model as if we were building with blocks:

  1. Parameter name:This is the field display name seen in the background management, such as “Event Start Date”, “Customer Industry”.
  2. Field call:This is the unique identifier that needs to be used when calling this field in the front-end template. It is recommended to use English letters and usually adopt camel case naming method (for example:activityStartTime/customerIndustry)。This name is crucial, as the front end uses it to “recognize” and retrieve the field content.
  3. Field Type:The Anqi CMS provides various field types to meet the input needs of different data:
    • Single-line text:Suitable for short texts, such as titles, abbreviations.
    • Numbers:Ensure that the data entered is purely numeric, such as prices, quantities.
    • Multi-line text:Suitable for longer descriptions, such as product features, event details.
    • Single choice, multiple choice, dropdown selection:These three types are very suitable for preset options, such as “Activity Status (Ongoing/Completed)” and “Product Color (Red, Blue, Green)”.When setting these types, the "Default Value" area becomes the place to define the option list, one option per line.
  4. Mandatory:According to business needs, some fields can be set as required to ensure that important information is not omitted.
  5. Default value:Set an initial value for the field to improve the efficiency of content publishing. For fields of selection type, it is used to set the optional items here.

When the custom field is set, save the model.After publishing the corresponding content model (for example, a new activity under the 'Event Model'), in the 'Other Parameters' area of the content editing interface, we can see the custom fields that have just been added and can fill in specific content for them.

Flexible calling and display of custom fields on the front-end page

Displaying the content of custom fields to users is a key step in the safety CMS content management loop. The safety CMS template engine syntax is similar to Django, very intuitive, mainly through double curly braces{{变量}}to output variable content, as well as{% 标签 %}Structure to use feature tags.

Call custom fields on a single document detail page:

When you enter a detailed page of an article, product, or event, the main data of the page usually goes through a name calledarchive(for an article or product) orcategoryThe global variable to carry for the category page.authorDirectly associated with the document, you can directly through{{ archive.author }}This is the form of outputting its content.

If your custom field is a group of images, checkboxes, or other complex types, or if you want more flexible control over the output, you can usearchiveDetailTags:

`twig {# Directly retrieve the content of custom fields by name, for example, the article author #}

Author: {% archiveDetail with name=“author” %}

{# If the custom field content contains HTML, you need to use the |safe filter to prevent escaping #}

产品简介:{% archiveDetail productIntro with name=“productIntro” %}{{ productIntro|safe }} English

{# Call the custom field of the image group, such as “Product Group Image”, it will return an array, which needs