How to customize a flexible content model in AnQiCMS according to business needs to achieve personalized display?

In a rapidly changing network environment, website content is no longer just a pile of articles and images.Whether it is small and medium-sized enterprises showcasing diverse products and service cases, or self-media operators publishing event notices and in-depth reviews, it is required that the content be presented in a way that is most closely aligned with business logic and user needs.Traditional CMS often provides fixed content types, which are difficult to adapt to personalized needs, but AnQiCMS's flexible content model design exactly solves this pain point.

Why is a customized content model crucial for your business?

Imagine that your website needs to display:

  • a company'steam membersEach member has a name, position, introduction, avatar, and areas of expertise.
  • OneProduct details pageIn addition to the usual images and descriptions, it is also necessary to list the specifications in detail (such as size, material, color options), even a link to customer reviews.
  • OneEvent listEach activity includes the topic, time, location, registration method, speaker, and event poster, etc.

If relying solely on the general models of "article" or "product

The purpose of the custom content model is right here.It allows you to tailor data structures according to the unique properties of each business content.In this way, not only has the clarity and organization of content entry in the background improved, but the relevance between content has also become stronger. Moreover, when presented on the front end, it can accurately retrieve the required fields, realize a highly personalized and unified style layout, and greatly enhance the adaptability and user experience of the website.

Build and apply custom content models in AnQiCMS

AnQiCMS provides an intuitive interface for creating and managing these personalized content structures. The entire process is as simple as stacking building blocks.

1. Create or modify the content model

First, you need to enter the AnQiCMS admin interface, find the "Content Management" under the "Content Model" feature.Here you will see the system default built-in 'article model' and 'product model'.They are the foundation of your daily content posting, of course, you can also modify them according to your needs, but you cannot delete them.

To create a new content type, such as an “event” model, you need to click on “Add Model” and fill in some basic information:

  • Model nameThis is a Chinese name, such as 'event', 'team member', 'real estate information', used for identification and management in the back-end interface.
  • Model table nameThis is the table name stored in the database by the model, it needs to be a unique combination of lowercase English letters, the system will automatically suggest it for you, just keep the default, as it is closely related to the underlying logic of data storage.
  • URL aliasThis name will be reflected in the URL on the website front end, for example, if you create a "Event" model, its URL alias can be set aseventThen the event list page may be/event/list.htmlThis helps search engine optimization and user memory.
  • Title NameThis field will replace the default "Document Title" prompt, making it clearer for content entry personnel what the main content of the current model is, such as "Event Topic", "Product Name", or "Member Name".

2. Define model fields: The \

This is the most core part of the custom content model.When creating or modifying a model, you can add exclusive custom fields to the model.

  • Single-line text: Suitable for storing brief text information, such as \
  • Number: Used for storing numerical values, such as 'activity cost', 'product inventory', 'property area', for easy calculation or sorting.
  • Multi-line text: Suitable for storing long text descriptions, such as 'Activity Detailed Introduction', 'Team Member Introduction'.You can choose to enable the Markdown editor to achieve rich text editing, including inserting images, videos, even mathematical formulas and flowcharts, making the content richer.
  • Single choice: Use when you need to select one from several preset options, such as 'Activity Type' (online/offline), 'Property Use' (residential/commercial).
  • Multiple selections: Allow selection of one or more predefined options, such as "Product Features" (waterproof/dustproof/long battery life).
  • Drop-down selectionSimilar to single selection, but presented in a dropdown menu format, suitable for situations with more options, such as 'Product Color' (red/blue/green/black/white).

Each custom field needs to be set when created:

  • Parameter Name: This is the Chinese name displayed in the background interface and template, convenient for you to understand and call.
  • Field invocationThis is the English identifier called through the code in the template, it is recommended to use concise and clear English words.
  • Mandatory?Ensure that important information is not missed.
  • Default valueSet a default value for the field, especially suitable for selection fields, as an option list.

These flexible field combinations allow you to build the perfect "skeleton" for any complex business content.

3. Apply custom models to content publishing

After the model is defined, its role is reflected in content management.When you enter the 'Content Management' 'Add Document' interface and select a 'Category' associated with your custom model, something amazing happens—the page will automatically load and display all the custom fields you have defined for the model.

For example, if you select a category under the "ActivityThis enables content entry personnel to fill in information efficiently and accurately, greatly reducing the possibility of errors.

4. Implement personalized display in front-end templates

With structured content data, the next step is how to elegantly display them on the front end of the website.AnQiCMS uses a syntax similar to the Django template engine, allowing you to easily retrieve and render these custom data through rich template tags.

  • Get details of a single document (archiveDetail)When you are on the event details page, and need to display specific information of an event, you can usearchiveDetailLabel. For example, to display the "Activity Topic" field, if its "Call Field" isevent_title, you can write it like this:{% archiveDetail with name="event_title" %}For multiline text types (such as event descriptions), if you want the HTML content to be parsed correctly, don't forget to add|safeFilter:{{archiveContent|safe}}. If you need to cyclically display a list of images for a field (such as a multi-angle display of a product), and the "call field" of the custom field isproduct_images, then you can use:

    {% archiveDetail productImages with name="product_images" %}
    <ul class="product-gallery">
      {% for img in productImages %}
      <li><img src="{{img}}" alt="产品图" /></li>
      {% endfor %}
    </ul>
    
  • Get document list (archiveList) On the event list page, you may need to display the summary information of each event.archiveListTag in the loop, eachitemVariables will also include all custom fields. For example, display the title and location of each event:

    {% archiveList events with moduleId="您的活动模型ID" type="page" limit="10" %}
        {% for item in events %}
        <div class="event-card">
            <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
            <p>活动地点: {{item.event_location}}</p> {# 假设调用字段是 event_location #}
            <p>活动时间: {{stampToDate(item.event_time, "2006-01-02 15:04")}}</p> {# 假设调用字段是 event_time #}
        </div>
        {% endfor %}
    {% endarchiveList %}
    
  • Iterate over all custom parameters (archiveParams)Sometimes, you may need to dynamically display all custom fields and their values of a document in a general area without knowing the field names in advance.archiveParamsLabels come in handy:

    {% archiveParams params %}
    <div class="custom-fields">
        {% for item in params %}
        <p><strong>{{item.Name}}:</strong> {{item.Value}}</p>
        {% endfor %}
    </div>
    {% endarchiveParams %}
    

    This is very useful in the "Product specifications" area, where you do not need to manually list each parameter, the system will automatically display it.

By using these flexible template tags and filters, you can accurately control the display position, style, and content of page elements based on the data in a custom content model, truly realizing personalized display of website content.Whether it is to build a complex e-commerce website or an information-rich industry portal, AnQiCMS' content model can provide you with solid underlying support.

Summary

The flexible content model of AnQiCMS has opened up a new world in content management.It no longer confines your content to predefined frameworks, but instead gives you complete freedom to define various content types and their unique properties according to the actual business needs.