Unlock the potential of content: Use the flexible content model of AnQi CMS to customize the display structure

In today's rapidly changing digital world, website content is no longer just simple articles and pages.For many operators, it may include a variety of products, captivating activities, professional detailed project cases, and even unique team member introductions.Traditional content management systems (CMS) often use fixed content structures, forcing diverse information to squeeze into the boxes of 'title' and 'body', resulting in a monotonous display of content and a severely compromised user experience.

The Anqi CMS is exactly born to solve this pain point.It provides an extremely flexible content model, allowing us to customize the structure and display of each type of content as if we were stacking blocks, based on actual business needs.This is not just the convenience of backend data entry, but also a revolutionary improvement in the presentation effect of front-end content.

Why is the content model so important?

Imagine that you are running an e-commerce website.Traditional CMS might only give you input boxes for “Product Title” and “Product Details”.But in fact, a product may also need multiple attributes such as 'price', 'stock', 'brand', 'model', 'color', 'size', 'material', and more.If all this information is stuffed into the "Product Details", it not only becomes chaotic to manage, but users also find it difficult to quickly obtain key information.

A flexible content model allows you to create dedicated data fields for different types of content, just like customizing a 'ID card' for each type of content. For example:

  • Product contentCan have fields such as 'price', 'SKU', 'brand', 'image set', 'product specifications', etc.
  • Event contentThe content can include fields such as 'Event Date', 'Event Location', 'Registration Deadline', 'Keynote Speakers', etc.
  • Project CaseYou can define fields such as 'Customer Name', 'Industry Field', 'Pain Points Solved', 'Implementation Effectiveness', etc.

This customized content structure can help your website present information more clearly and logically, enhance user experience, and even have a positive impact on Search Engine Optimization (SEO), as structured data is easier for search engines to understand and index.

How does AnQi CMS implement content model customization?

In AnQi CMS, the customization experience of the content model is very intuitive.You can find the 'Content Model' feature under the 'Content Management' in the backend.The system is pre-installed with 'Article Model' and 'Product Model', but you can create a new custom model as needed.

Taking the creation of a 'project case' model as an example, we need:

  1. Define model basic informationSet a 'model name' that is easy to identify for the model (such as: project case), and define a 'model table name' for database storage and a 'URL alias' for URL construction (usually in lowercase English letters).
  2. Add Custom FieldsThis is the core of the content model. You can add a series of exclusive fields for "Project Case", such as:
    • Parameter name(For example: "Customer Name"): This is the friendly name displayed to the content editor on the back-end interface.
    • Call field(For example: “clientName”): This is the unique identifier used when calling this field in the template, and it is recommended to use camelCase naming style.
    • field typeThe [en] provides various field types to match your data needs:
      • Single Line TextSuitable for brief text information, such as “Customer Name”, “Industry Field”.
      • Number[en] : Applies to numeric data, such as 'project budget', 'completion cycle'.
      • Multi-line text[en] : Applies to longer descriptive text, such as 'pain points addressed', 'customer feedback'.
      • Single selection/Multiple selection/Drop-down selectionThis is applicable to predefined options data, such as 'Project Status' (Ongoing/Completed), 'Collaboration Type' (B2B/B2C).You can provide a specific list for these options in the 'Default Value', with one option per line.
    • Is requiredYou can set certain fields as required based on their importance to ensure the completeness of the content.

After defining the model and fields, the next step is to apply these models to your content.When creating a 'Document Category', you can choose to bind the category to a specific content model (for example, binding the 'Project Case' category to the 'Project Case' model).Thus, all content under this category will follow the field structure defined by the 'Project Case' model for entry.

Present custom content on the website front end

How to elegantly display this information on the front end of the website after customizing the content model is the key to achieving personalized display.The AnQi CMS adopts Django template engine syntax, allowing you to easily call these custom fields in template files.

Firstly, you need to understand the organization structure of the template file. The template files of Anqi CMS are usually stored in/templatedirectory, and classified according to the model or page type (for example,{模型table}/detail.htmlUsed to display the detailed content under the model).

When you need to display custom model fields, you can usearchiveDetailandarchiveParamsthese two tags:

  • archiveDetailtagsUsed to obtain detailed information about the current document, including all custom fields. You can directly call it by field name. For example, on the details page of 'Project Cases'project/detail.htmlIf you define the "Customer Name" (called fieldclientName), and the "Industry Field" (called fieldindustry), you can display them like this:

    <h1>{{ archive.Title }}</h1> {# 默认标题字段 #}
    <div>
        <strong>客户名称:</strong> {% archiveDetail with name="clientName" %}<br>
        <strong>行业领域:</strong> {% archiveDetail with name="industry" %}<br>
        {# 假设还有一个多行文本字段 'solution' #}
        <strong>解决方案:</strong> {% archiveDetail solution with name="solution" %}{{solution|safe}}<br>
    </div>
    <div class="project-content">
        {{ archive.Content|safe }} {# 默认正文内容,记得使用 |safe 防止HTML转义 #}
    </div>
    
  • archiveParamstagsIf you want to loop through all custom fields or are unsure of the specific field names,archiveParamsIt will be very useful. It will return an array containing all custom parameters, and you can iterate over this array to display.

    <div>
        <h3>项目参数:</h3>
        {% archiveParams params %}
        <ul>
        {% for item in params %}
            <li><strong>{{ item.Name }}:</strong> {{ item.Value }}</li>
        {% endfor %}
        </ul>
        {% endarchiveParams %}
    </div>
    

    This is especially convenient when you need to dynamically add or modify model fields without frequently modifying the template.

For fields like 'Multiple Choice' or 'Dropdown Selection' that may return multiple values, you would typically receive them as an array and iterate over them in the template to ensure all options are clearly displayed.

Practical Tips for Optimizing Content Display

In addition to custom content structure, Aike CMS also provides other features to further optimize content display and user experience:

  1. Custom URL Rewrite RulesThrough the "pseudo-static rule" settings on the backend, you can customize more semantically meaningful and SEO-friendly URL structures for different content models, categories, or documents. For example, you can set the URL for the detail page of the "Project Case" to be:/projects/{filename}.htmland is no longer just simple/article/{id}.html. This not only improves user memorability, but also allows search engines to better understand the content of the page. You can make use of{module}/{filename}etc. to flexibly construct URLs.

  2. Category template and document templateWhen certain categories or individual documents require a completely different layout or display style, Anqi CMS allows you to specify dedicated template files for them. For example, a template file can be specified for the "Recruitment Information" category.job/list.htmlTemplate, to display job salaries, locations, and other key information in card format on the list page; or to specify a significant "About Us" single pagepage/about_us.htmlTemplate, featuring a unique visual design. This allows for the ultimate personalized display of content.

  3. Multilingual content displayIf your website is targeted at international users, the multilingual support feature of AnQi CMS can be perfectly integrated with the content model. You can define corresponding fields for different language versions in the content model and throughlanguagesLabels provide language switching options on the front end, ensuring that users from different regions can see content that matches their habits.

Concluding remarks

The flexible content model of AnQi CMS brings unprecedented freedom to your website content management. It frees you from the constraints of traditional CMS, allowing you to precisely define and display each type of content, thereby creating