Today, with the increasing refinement of content operation, we often find that relying solely on traditional 'article' and 'product' categories is no longer sufficient to meet the diverse content display needs of websites.Every business scenario has its unique attributes and information structure. How to make the website's content management system (CMS) act like a considerate tailor, customizing 'clothing' for each type of content, is our goal.The flexible content model function provided by AnQiCMS (AnQiCMS) can exactly help us realize this vision.

Why do we need to customize the content model?

Imagine if your website not only publishes articles and products but also needs to display real estate information, job vacancies, event schedules, and even team member introductions.Every content type has its unique fields: real estate may require 'apartment type', 'area', 'price', 'location'; recruitment may require 'position name', 'salary range', 'work location', 'job responsibilities'; and events may require 'start time', 'end time', 'location', 'participation fee' and so on.

If forcing this rich information into a generic "article" template, it is not only inefficient during backend entry but also prone to appear disorganized and unprofessional on the frontend.Information cannot be structured stored, meaning it is difficult to perform precise filtering and sorting, and it also cannot provide clear structured data for search engines, thereby affecting user experience and SEO effectiveness.

In the Auto CMS, create a custom content model

In the Auto CMS, creating and managing content models is an intuitive and powerful process.You can go to the "Content Management" section of the background to find the "Content Model" option.Here, you will see the built-in 'Article Model' and 'Product Model'—they are predefined general content structures.To meet personalized needs, we usually choose to "add a custom model".

After clicking the 'Add Model' button, you need to define some basic information for the new model:

  • Model name:This is the Chinese name used for identifying and managing models in the background, such as "Real Estate Information
  • Model Table Name:This is the English identifier used by the system to store data in the database, it is recommended to use lowercase letters and numbers to ensure uniqueness. It determines how the data is organized on the backend.
  • URL Alias:Used to generate static links, it is also recommended to use English lowercase letters, which will be part of your content URL and is very important for SEO.
  • Title Name:This is the prompt text for the main title of the content when publishing, such as 'Product Name' or 'Real Estate Title', making it clear for the content editor.

The essence of customizing the content model is next—Define model fields.Here, you can add exclusive fields for your content according to your actual needs.

  • Single-line text:Suitable for brief text information, such as 'property title', 'contact phone', 'job position'.
  • Numbers:Can only input numbers, suitable for fields that require numerical calculations or range filtering, such as "area
  • Multi-line text:Suitable for inputting longer descriptive text, such as "Real Estate Details
  • Single choice:Allow you to preset multiple options, but the content publisher can only choose one, for example “House type (residential/commercial/villa)”、“Article source (original/reprint)”.
  • Multiple selection:Similarly, multiple options can be preset, but content publishers can choose one or more, for example, "House characteristics (elevator/parking space/school district)", "Product features (waterproof/earthquake-proof/touch screen)", and "English".
  • Dropdown selection:Similar to single selection, but presented in the form of a dropdown menu, suitable for situations with a large number of options, such as “Area of residence (Haidian/Chaoyang/Fengtai)” and “Product color (Red/Blue/Black).” }]

When defining each field, you can also set 'Is Required' to ensure that key information is not missed; as well as 'Default Value', providing convenient preset options for some commonly used fields.These settings greatly enhance the efficiency and standardization of content entry.

Publish and manage personalized content

When you have created a custom content model and defined all fields, it will seamlessly integrate into the content publishing process of the Anqi CMS.Under 'Content Management', when you select 'Add Document' or 'Add Product', you will notice an important change: you first need to select a 'Category'.

This category is closely related to the model you created.Once you select a category bound to a custom model, in the document editing interface, in addition to the existing title, content, keywords, etc. general fields, you will see a collapsible area called "Other parameters".Expand this area, all the custom fields you define will be listed clearly, waiting for you to fill in the corresponding data.

Such design ensures that each type of content can be entered according to its unique structure, which is both standardized and efficient.

Display custom content in the front-end template

The real magic of the custom content model lies in how it is flexibly presented on the website frontend.The AnQi CMS adopts Django template engine syntax, allowing you to convert structured data stored in the background into rich and diverse page content with concise tags.

To call a custom model field in a template, several core tags will be mainly used, the most important of which isarchiveDetailandarchiveList。They are used to get the details of a single content and the list of contents. And for the fields we define ourselves,archiveParamsthe tag is its exclusive “extractor”.

For example, when you are on the content detail page (usually correspondingarchiveDetail), you can usearchiveParamsto iterate through and display all custom fields:

{% archiveParams params %}
    {% for item in params %}
    <div>
        <strong>{{item.Name}}:</strong>{# 显示字段的中文名称,如“面积” #}
        <span>{{item.Value}}</span>{# 显示字段的值,如“120平米” #}
    </div>
    {% endfor %}
{% endarchiveParams %}

This code will intelligently traverse all custom fields defined for the current content model and display them in the form of 'Field Name: Field Value'.This is very useful for pages that need to fully display content attributes.

If you know the specific "call field" name of a custom field (for example, if you define a field namedarea), you can also access it directly througharchiveobject:

<div>
    <strong>房屋面积:</strong>
    <span>{{archive.area}} 平米</span>
</div>
<div>
    <strong>装修情况:</strong>
    <span>{{archive.decoration_status}}</span>
</div>

This direct access method allows you to be more flexible when designing specific layouts, enabling you to precisely embed custom fields into any position of the page elements as needed.

Moreover, if you have defined filterable fields in your custom model (such as the 'type' of property), the Anqi CMS'sarchiveFiltersTags can also help you build powerful filtering functions on the list page.Users can filter content based on these custom fields, greatly enhancing the discoverability and user experience.

The flexible content model of AnQi CMS opens up endless possibilities for website content design. Whether it is building complex industry portals or creating personalized corporate websites, it can provide strong...