AnQi CMS is an efficient and customizable content management system, one of its core advantages is the flexible content model.This provides website operators with a great degree of freedom, allowing us to design unique structures and display methods for various content types such as 'articles', 'products', and more, thus realizing personalized presentation of website content.

Next, we will delve into how to take advantage of the powerful functions of Anqi CMS to achieve personalized display of content models.

Understanding the content model of Anqi CMS

In AnQi CMS, the content model is the skeleton that defines the structure of a certain type of content data.It determines which fields can be filled in and the types of these fields when we publish and manage content in the background.The system provides the commonly used "article model" and "product model" by default, each with a set of basic fields preset to meet the basic needs of article and product publishing.

However, the content of a website is often not limited to this. For example, a real estate website may need a "house model" that includes fields such as "house type", "area", "price", "location", and so on;A recruitment website may need a "job model", including "job title", "salary range", "work location", "publishing department", and so on.The Anqi CMS allows us to fully customize new content models and add exclusive custom fields for each model, which is the first step in achieving personalized display.

Core Strategy One: Use custom fields to enrich the content structure.

The personalized display of content primarily depends on whether the structure of the content is rich and accurate.The AnqiCMS custom field function allows us to add unique data items based on the specific characteristics of each content model.

For example, forArticle modelWe may also add fields such as title, content, publish time, etc.

  • Author: Single line text, recording the author of the article.
  • Source: One-line text, indicating the original source link or name of the article.
  • Reading time: Numeric type, estimated time required for readers to finish reading the article.
  • Recommended attributeMultiple selections, such as 'Top News', 'Recommendations', 'Sliders', etc., for easy display in different regions.

And forProduct modelTo better showcase the product features, we can add:

  • Product Model: Single-line text, precise product code.
  • Price: Numeric type, product selling price.
  • Inventory: Numeric type, current available stock of the product.
  • Main featuresMulti-line text highlighting the core advantages of the product.
  • Parameter listMulti-line text for entering detailed technical parameters of the product, which can be parsed into a table on the front-end.
  • Product album: Gallery type, upload multiple product images to create a carousel effect.

How to operate?In AnQi CMS backend, you can find the "Content Model" option under "Content Management".Here, you can modify existing models (such as articles, products) as well as “add new models”.In the model editing interface, you can add 'custom fields' to the model.Each field can be set to parameter name (front-end call name), field type (single-line text, number, multi-line text, single selection, multiple selection, dropdown selection, etc.), whether mandatory, and default value.For example, add a single-line text field named "Product Model" whose called field can beproductModel.

These custom field settings directly determine which information we can fill in when publishing content on the back end, and also lay the foundation for personalized display on the front end.

Core strategy two: Customize exclusive templates for different content models

With structured content, the next step is how to present them on the frontend page in a way that conforms to their type.The Anqi CMS template system provides high flexibility, allowing us to customize exclusive display templates for different content models, even specific categories or single pages.

The template files of AnQiCMS are usually named with.htmlsuffix and stored in/templateUnder the directory. Its template syntax is similar to the Django template engine, through{{变量}}to output data,{% 标签 %}Logical control is performed.

The system supports custom template names and can be applied automatically. For example:

  • The default template for the article detail page might bearticle/detail.html.
  • The default template for the product detail page might beproduct/detail.html.
  • The default template for the article list page might bearticle/list.html.
  • The default template for the product list page might beproduct/list.html.

In addition, more fine-grained personalized control lies in the fact that we canspecific categoriesorsingle content pieceSpecify the use of an independent template file:

  • In the "Document Category" settings, you can specify a "category template" for a category, for example, for the "Company News" category specifynews/list.htmlMake it consistent with the "Industry Information"industry/list.htmlDisplay style is different.
  • When adding a document or a product, you can specify a document template in the "Other parameters", for example, for a special productspecial_product/detail.htmlto have a detailed page layout that is completely different from that of ordinary products.
  • Even a single page can be customized, such as specifying a template for the "Contact Us" page.page/contact.html.

How to operate?Firstly, you need to/template/您的模板目录Create the corresponding template file, for examplearticle/detail.html/product/detail.html. If you want to specify a unique template for a category or document, for examplespecial_product/detail.htmlCreate the file as needed. Then, when editing the category or document in the background, enter the corresponding filename in the "Category Template" or "Document Template" field (such asspecial_product/detail.html), the system will load the corresponding template according to your settings.

Core strategy three: skillfully use template tags and filters to display personalized content.

With custom fields and dedicated templates, the final step is to extract the data through specific tags and filters in the template and present it in a beautiful and practical manner.

1. Extract content model data:archiveDetailandarchiveListThese tags are the core for fetching article, product and other content data.

  • {% archiveDetail with name="Title" %}It can fetch the title of the current content.
  • `{% archiveDetail with name=“Content” %