How to customize the AnQiCMS content model to achieve personalized page content display?

Calendar 👁️ 73

AnQiCMS content management system provides us with powerful content management capabilities with its excellent flexibility and customizability.In the daily operation of websites, we often encounter situations where the standard "article" or "product" model cannot fully meet the needs of specific business scenarios.At this time, the content model customization feature of AnQiCMS is particularly crucial, as it allows us to build personalized content structures based on the unique needs of the website, thereby achieving more precise and expressive page content display.

Why do you need to customize the content model?

Imagine if your website needs to publish content such as "job information", "course schedule", "successful cases", or "project reports", etc., these contents often contain specific fields in addition to titles, content, and images, such as the job information may require "location of the position", "salary range", and "education requirements".The course schedule may require "class time", "instructor", "class hours", etc.If we rely solely on the inherent 'article' model, we may need to squeeze these key pieces of information into the main text, or use irregular methods to process them, which not only leads to chaos in backend management, but also makes the front-end display difficult and lacks structure.

The benefits of a customized content model lie in the fact that it can make your content management more refined and structured.By defining dedicated fields for different types of content, we can ensure data integrity and consistency, improve content management efficiency, and more importantly, provide rich and structured data sources for front-end pages to achieve highly personalized content display.

How to create or modify a content model in AnQiCMS?

The content model management interface of AnQiCMS is intuitive and easy to use, allowing us to easily define the skeleton of the content.

First, you need to log in to the AnQiCMS backend and navigate to“Content Management”Under the menu“Content Model”. Here you will see the built-in 'article model' and 'product model'.Of course, to meet more personalized needs, we can choose to 'Add Model' to create a completely new content type.

When creating or modifying a content model, there are several core configuration items that we need to consider carefully:

  1. Model name:This is the Chinese name used to identify the model in the background management interface, for example, "Recruitment Information", "Course Model". It is convenient for us to quickly distinguish between different types of content.
  2. Model table name:This is the table name stored in the database for the custom field of the model, which must be in lowercase letters. Once set, it is generally not recommended to modify it arbitrarily to avoid data problems.
  3. URL alias:The identifier used in the front-end page URL, it is also recommended to use lowercase letters.This is crucial for building SEO-friendly URL structures.For example, the URL alias for a recruitment information can bejobsThen the front-end list page may be/jobs/list.html.
  4. Title Name:This is the prompt text for the main title input box when publishing content, such as 'Position Name', 'Course Title', which can better guide the content editor to fill in the correct information.

Custom field: The key to implementing personalized content

The core of the content model lies in its custom fields. On the model settings page, you can add various types of fields according to your actual needs, which will determine the information you need to fill in when publishing content, as well as the data that the front-end can obtain and display.

Click "Add field" and you will need to configure the following key properties:

  • Parameter name:This is the background content editing page, the display name of this field, for example, "Position Location", "Salary Range". It should be clear and understandable.
  • Call field:This is the variable name used when calling this field in the front-end template, it must be alphabetic, and it is recommended to use camel case (such asjobLocationThis name will directly determine how you retrieve the data field in the template.
  • Field type:AnQiCMS provides various field types to adapt to different data formats:
    • Single-line text:Suitable for short text input, such as contact information, job titles.
    • Number:Suitable for numeric input, such as price, quantity.
    • Multi-line text:Suitable for longer text content, such as job descriptions, course introductions.
    • Single choice:Provide multiple options but only one can be selected, such as 'Gender', 'Region'.
    • Multiple selection:Provide multiple options that can be selected, such as 'Skill Tags', 'Suitable Audience'.
    • Dropdown selection:Similar to single choice, but presented in the form of a dropdown menu, suitable for situations with many options.
    • Choose an appropriate field type to ensure the standardization and ease of use of data.
  • Mandatory?:Check this box, the field must be filled in when publishing content to ensure the completeness of key information.
  • Default:You can set a default value for the field, or preset options for single-choice, multiple-choice, and drop-down selection fields.

By reasonably planning these custom fields, your content will have a clear structure, laying a solid foundation for subsequent personalized display.

Associate the content model with the content.

The association of content model with specific content is through AnQiCMSCategoryTo be implemented. Each category must belong to one and only one content model.This means that when you create a new category (such as "Front-end Development Position") and specify it as the "Recruitment Information" model, all content published under this category will follow the field structure of the "Recruitment Information" model.

When we enter the 'Publish Document' page and select a category that belongs to a specific content model, the 'Other Parameters' section of the content editing area will automatically display all the custom fields defined by the content model, for the content editor to fill in.This dynamic adaptation mechanism greatly simplifies the content publishing process, avoiding unnecessary field interference.

Individualized display is achieved in the front-end template

Completed the definition and release of the content model, and the next step is how to display these structured contents in a personalized way on the website front-end.AnQiCMS uses a template engine syntax similar to Django, which makes template creation both powerful and flexible.

1. The convention of template files and model-specific templates

AnQiCMS template creation follows certain conventions: the template files are located/templateUnder the directory. For the content model, AnQiCMS supports template files specific to the model. For example, if you create a model table namedjob: model table name

  • Model list page:can createjob/list.htmlAs the list page template for all categories under this model.
  • Model detail page:can createjob/detail.htmlAs the detail page template for all content under this model. You can even specify an independent template file for a specific category or document, for examplejob/list-123.htmlOr for the category list with ID 123job/remote-jobs.html(Specify this template for a specific category or document in the background).

2. Call custom fields

In the template file, we can use specific tags to retrieve and display custom fields defined in the content model:

  • Call through content tags directly:InarchiveDetailOr (document details)archiveList(Document list) In the loop body of the (Document list) tag, you can directly access custom fields using dot notation. For example, if your custom field调用字段is set tojobLocation, you can directly use it in the template.{{item.JobLocation}}Show its value. "twig {% archiveDetail archive with name="Content" %} {# 获取当前文档的详情数据,并赋值给 archive 变量 #} <h3>{{archive.Title}}</h3> <p>职位地点:{{archive.JobLocation}}</p> {# 直接调用自定义字段JobLocation` #} <

Related articles

How to ensure that the multi-site content of AnQiCMS can be displayed and managed uniformly on the front-end?

In today's complex digital environment, many businesses and content creators often need to manage multiple websites, whether they have multiple brand sub-sites, different product line portals, or provide services for multilingual users.How can it be ensured that each site operates independently while also achieving unified display and efficient management of content on the front end, which has become a common challenge.AnQiCMS as an enterprise-level content management system, provides a powerful and flexible solution in this regard.

2025-11-08

How to safely remove all or part of a specified tag from HTML content in AnQiCMS templates?

When building a website with AnQiCMS, we often need to finely control the content displayed on the page.Especially when dealing with user submitted content, importing articles from different sources, or simply to maintain consistency in page style, you may encounter the hassle of HTML tags.These tags may contain unnecessary formatting, styles, and even potential security risks.Fortunately, the AnQiCMS template system provides a flexible mechanism to help us safely and efficiently remove all or part of the specified tags from the HTML content.

2025-11-08

How to display the singular or plural form of a word based on the quantity value in the AnQiCMS template?

When building a website, we often encounter situations where we need to dynamically display text based on a certain quantity value.For example, when there is '1 comment', we want to display it in singular form; while for '2 comments', it should be displayed in plural form.This detail handling not only improves user experience but also shows the professionalism of the website content.If manual quantity judgment and writing if/else logic make the template code long and difficult to maintain.

2025-11-08

How to convert letter combinations like 'PONGO2' into the corresponding numbers on a phone keypad?

How to easily convert letter combinations to phone number keypad digits in AnQiCMS?In daily life, we sometimes encounter some phone numbers composed of letters and numbers, for example, some companies may use memorable numbers like "999-PONGO2" for brand promotion.However, when making a phone call in reality, these letters need to be converted into the corresponding numbers on the phone keypad.For website operators, if they can automatically complete this conversion on the website front end, it will undoubtedly greatly improve the user experience.

2025-11-08

How does AnQiCMS support the switching of multilingual content and the correct display on the front-end page?

AnQiCMS provides powerful multilingual support capabilities, helping websites easily meet the needs of global content promotion.Understand its working principle and configuration method, which can help you efficiently manage content in different languages and display it correctly on the front-end page. ### The Foundation of Multilingual Content Management: Multi-Site Mode One of the core ideas of AnQiCMS for implementing multilingual content switching is to make use of its powerful multi-site management function.This means, typically, you would create a separate site instance for each target language.

2025-11-08

How to optimize the display form of website URLs in search engines with the help of pseudo-static and 301 redirection functions?

In website operations, a clear, readable, and SEO-friendly URL structure is a key element in improving website visibility and user experience.AnQiCMS (AnQiCMS) knows this point, therefore it builds in these two important functions of pseudo static and 301 redirection, aiming to help users easily optimize the display form of the website in search engines, thereby bringing better ranking and traffic performance.

2025-11-08

How to ensure that the data collected through content acquisition and batch import can be displayed quickly on the front page?

In website operation, efficient content management is the key to improving user experience and SEO effectiveness.AnQiCMS (AnQiCMS) relies on its powerful content collection and batch import functions, greatly reducing the burden of content construction.However, we often encounter a core issue: How can we ensure that the content imported or collected through automated means is displayed on the front page to the user quickly and without delay?The Anqi CMS was designed with efficiency in content management and timely front-end display in mind, its underlying mechanisms and operational strategies can effectively help us solve this problem

2025-11-08

How does the AnQiCMS Sitemap tool improve the visibility of a website on search engine results pages?

In today's highly competitive online environment, ensuring that your website content is discovered and displayed at the top of search engine results pages (SERP) is fundamental for enhancing brand visibility and attracting potential users.AnQiCMS (AnQiCMS) is well aware of this as a content management system designed specifically for small and medium-sized enterprises and content operation teams.It comes with a powerful Sitemap tool designed to help users efficiently optimize their websites, thereby significantly improving their visibility in search engines.What is a Sitemap?

2025-11-08