In website operation, we often encounter such a demand: different content types require different display methods.The layout of a news article may be quite different from a product detail page, and a team member introduction page may have its own unique style.The flexible content model of AnQiCMS is designed to address this pain point, allowing us to deeply customize the structure of the content and the final display layout, thereby providing a **superior** browsing experience for visitors.

Understanding the core value of the content model

One of the core advantages of Anqi CMS is its 'flexible content model' feature.In simple terms, the content model is like the 'skeleton' and 'identity proof' of the content.It defines which fields a certain type of content should include (for example, articles have titles, authors, publication dates; products have names, prices, inventory, and product image sets), as well as the types of these fields.

The value brought by this flexibility is huge. We can customize various content structures according to business needs, such as:

  • Article Model:Including title, content, keywords, abstract, and cover image.
  • Product Model:Contains product name, detailed description, price, stock, product parameters (such as color, size), and multi-angle pictures.
  • Case model:Contains case title, customer name, completion date, case details, and related images.
  • Team member model:Contains name, position, personal introduction, avatar, and social media links.

By creating dedicated models for each content type, not only can we manage and input content more efficiently, but more importantly, it lays the foundation for customizing the display layout of these contents on the front end.

Build your custom content model

To start creating or adjusting the content model, we can go to the 'Content Management' section of the Anqi CMS backend and find the 'Content Model' option.The system usually comes with built-in models for articles and products, among other common uses. We can choose to modify them or add custom models as needed.

When creating a new model, the following key points should be noted:

  1. Model name and table name:The model name is the Chinese name displayed on the back-end, which is convenient for identification.The model table name is the identifier for data stored in the database, usually recommended to use lowercase English letters, and it cannot be changed once set, so it needs to be handled with care.
  2. URL Alias:This name will be used in the frontend URL, which is very important for SEO, and it is also recommended to use lowercase English letters.
  3. Custom field:This is the most flexible aspect of the content model. We can add various custom fields to precisely define the content structure.
    • Single-line text:Suitable for brief information, such as product model, author name.
    • Numbers:Suitable for prices, inventory, quantities, etc.
    • Multi-line text:Suitable for longer descriptions, such as product introductions, article summaries.
    • Single choice/multiple choice/dropdown selection:Applicable to preset options, such as product color, service type.
    • Image set:Very suitable for product display, can upload multiple images.
    • Mandatory:Ensure important information is not missed.

For example, when creating a 'Product' model, we can add fields such as 'Price' (number), 'Product Features' (multi-line text), 'Color' (multiple choices), and 'Product Album' (image set).These custom fields will be directly associated with the content entry interface and will be called in the subsequent template design.

Content and classification fine management

After the content model is set up, when publishing content, we can select the corresponding category, and each category will be bound to a content model.This means that when we select a category bound to 'Product Model', the content entry interface will automatically display all fields defined in the product model, making content entry structured and efficient.

In addition, the Anqi CMS also supports specifying custom templates for specific categories or independent documents. This is a crucial feature, meaning that we can:

  • Use a unified article list and detail page template for all 'news' categories.
  • Use a standard detail template for all products under the 'Company Products' category, but customize a more attractive detail page template for the 'Star Products' subcategory.
  • Design a completely exclusive layout for a 'Special Recommendation' article or a single-page 'About Us'.

When setting categories or documents in the background, enter a custom template filename (such asproduct-special.html) in the "Other Parameters". This can achieve the purpose.

Flexiblely define the layout of content display

After we have a well-defined content model and a customized template application method, the next step is to implement the layout of these contents in the template file.The template system of Anqi CMS is based on a syntax similar to Django, which is powerful and easy to learn.

  1. Template file organization:The template files of AnQi CMS are located in/templatethe directory, which are usually organized according to content type and page function. For example,article/detail.htmlit could be the default template for the article detail page.product/list.htmlIt may be the default template for the product list page. When we want to customize the layout, we can create a new template file, for exampleproduct/detail-custom.htmlThen, in the background, it is assigned to specific product categories or the product itself.

  2. Application of core tags:In the template file, we mainly use the various tags provided by the Anqi CMS to obtain and display content.

    • archiveListandarchiveDetailTags: This is the core tag for obtaining the list of content (documents) and details.moduleId/categoryIdParameters such as [en] can be used to accurately obtain the desired content.
      • Standard fields to be displayed (such as [en])Title/Description), you can use it directly,{{item.Title}}or{{archive.Description}}.
      • For custom fields in the content model, we can directly access [en]{{item.自定义字段名}}or{{archive.自定义字段名}}Please visit. For example, if the product model has onepricefield, it can be used in the detail page template{{archive.price}}Show【en】.
      • If there are many custom fields or if you want to handle it more flexibly,archiveParamsLabels can retrieve all custom parameters of the current document and then forloop through and display them, such as: