In AnQiCMS, custom content models play a core role, which directly determines the structure and display of front-end article content.For content operators, understanding and making good use of this feature is the key to achieving personalized website content, improving user experience, and operating efficiency.

I. Understanding the Custom Content Model: The Foundation of Flexible Content Management

Traditional CMS systems may only provide the fixed content types of "articles" and "pages", but in actual operation, websites often need to display more diversified content, such as product details, event information, case studies, job positions, and more.Each content has its unique attributes and information composition.The customized content model of Anqi CMS is precisely designed to address this pain point.

It allows us to create and define new content types based on business needs, no longer limited by predefined formats.For example, you can create a content model named "product" instead of squeezing all product information into a regular "article" model.Thus, each content model is like a blueprint, clearly defining which data fields should be included in this type of content, thereby laying a solid foundation for personalized display on the front end.

II. Model field configuration and content entry: Define the 'skeleton' for display

In the backend management system of Anqi CMS, when creating or modifying a custom content model, we need to configure a series of dedicated fields for it.These fields are like the 'skeleton' of the content, determining the table for content entry and the data points displayed on the front end.

We can flexibly add various types of custom fields to meet the needs of different information storage:

  • Single-line text or multi-line text:Suitable for short titles, summaries, product descriptions, activity details, etc.
  • Numeric type:Data used for price, inventory, number of participants, ratings, and other numerical calculations.
  • Single-choice, multiple-choice, or dropdown selection:Used for preset categories or tags, such as product color, activity type, house type, etc., for convenient content standardization and frontend filtering.
  • Image/file upload:Allow uploading product image sets, event posters, attachment downloads, and more.

When we publish content in the background, we first select a category to which it belongs, and each category is associated with a specific content model.Once a category is selected, the editing interface will dynamically display the corresponding custom fields based on the definition of the content model.For example, if a category under the "ProductThis meticulously organized and entered data is the original material that enables the rich and personalized display of the front-end page.

III. The 'Magic' of the Front-end Template: Transforming Data into Visual Experience

An auto CMS uses a template engine similar to Django,{{变量}}and{% 标签 %}The syntax used to parse and display data. The value of a custom content model lies in the ability it gives template developers to precisely control the presentation of these custom fields on the frontend page.

  1. Get standard fields and custom fields: accurately locate contentFor each content item (usually through)archiveObject representation), its built-in standard fields such as title ({{archive.Title}}), content ({{archive.Content|safe}}), thumbnails ({{archive.Thumb}})et al. can be directly called using the double-brace syntax.While the invocation of custom fields is more flexible.material)'s custom field, in the product detail page template, we can use{% archiveDetail with name="material" %}such tags to retrieve and display its content. If you are accustomed to directly accessing object properties, you can also use{{archive.material}}The premise is that the template context containsarchiveThe object already contains this custom field. In this way, we can accurately display the product's material information at the specified location on the page.

  2. Traversal and dynamic display: dealing with complex data structuresCustom fields sometimes need to store more complex data, such as a product may have multiple display images, or an event may have multiple time periods.This, the template engine of Anqi CMS provides powerful iteration capabilities.arcimagesThe custom field (grouped image) stores multiple image URLs, and we can display it in the template like this: `twig {% archiveDetail arcimages with name=“arcimages” %}