How to manage custom fields in the content model of AnQiCMS and call them to display on the front-end page?

Calendar 👁️ 75

AnQi CMS is an efficient and customizable enterprise-level content management system, one of its core highlights is the "flexible content model".This feature greatly expands the management boundaries of website content, allowing us to create various unique content structures according to actual business needs.Among these, the custom field (also known as custom parameter) plays a vital role, allowing our website content to go beyond traditional article titles, content, and summaries, and carry more personalized information, ultimately displaying flexibly on the front page.

Flexible content model and the foundation of custom fields

Imagine a traditional CMS that might only provide two fixed content types such as 'articles' or 'products.'If we need to publish an 'event' or a 'case', which includes the start time, location, number of registrants, customer name, industry background, and other unique information, these fixed content types seem inadequate.

The flexible content model of AnQi CMS is precisely designed to solve such problems.It allows us to customize content types, such as creating an "event model" and adding a series of exclusive custom fields for this model.These custom fields are where the model carries specific information outside of the standard fields.They are the foundation of website personalized content, enabling each content model to accurately match its business attributes, thus achieving more refined and efficient content management.

Practical steps for creating and managing custom fields in the background

In the AnQi CMS backend, managing custom fields is an intuitive and powerful process.Generally, we need to go to the 'Content Management' menu to enter the 'Content Model' settings.Here, you will see the system built-in 'article model' and 'product model', and you can also create new content models.

Whether it is to edit an existing model or create a new model, the core steps are to enter the model details page, find the "Content Model Custom Fields" area. Here, we can add the required fields like building blocks:

  1. Parameter name:This is the field display name seen in the background management, such as 'Event Start Date', 'Customer Industry'.
  2. Call field:This is the unique identifier that needs to be used when calling this field in the front-end template. It is recommended to use letters to maintain code specifications, and usually in camel case (for example:activityStartTime/customerIndustry)。This name is crucial, as the front-end recognizes and retrieves field content through it.
  3. Field type:Anqi CMS provides various field types to meet the needs of entering different data.
    • Single-line text:Applicable for short texts, such as titles and abbreviations.
    • Number:Ensure that the entered data is purely numeric, such as prices and quantities.
    • Multi-line text:Suitable for longer descriptions, such as product features and event details.
    • Single choice, multiple choice, dropdown choice:These three types are very suitable for preset options, such as "Activity status (Ongoing/Completed)", When setting these types, the "Default Value" area becomes the place to define the option list, one per line.
  4. Mandatory?:According to business needs, some fields can be set as required to ensure that important information is not missed.
  5. Default:Set an initial value for the field to improve the efficiency of content publication. For selection type fields, it is used to set optional items here.

After the custom field is set up, save the model. After that, when publishing the corresponding content model (such as a new event under the "event model"), in the "other parameters" area of the content editing interface, we can see the custom field just added and can fill in specific content for them.

Flexible calling and display of custom fields on the front-end page

Presenting the content of a custom field to the user is a key step in the content management cycle of AnQi CMS. AnQi CMS's template engine syntax is similar to Django, very intuitive, mainly through double curly braces{{变量}}to output variable content, as well as{% 标签 %}Structure to use feature tags.

Call custom fields on a single document detail page:

When you enter a detailed page of an article, product, or event, the main data of the page will usually be accessed through a name calledarchive(for articles or products) orcategoryThe global variable to carry for the category page. If your custom field (assuming the called field isauthor) is directly associated with the document, you can directly access it through{{ archive.author }}This is the way to output its content.

If your custom field is an image group, a checkbox, or other complex type, or if you want to have more flexible control over the output, you can usearchiveDetailTags:

`twig {# Directly retrieve the content of a custom field by name, such as the author of an article #}

Author: {% archiveDetail with name=“author” %}

If custom field content contains HTML, the |safe filter must be used to prevent escaping #

Product Introduction: {% archiveDetail productIntro with name=“productIntro” %}{{ productIntro|safe }}

{# Call the custom field of the image group, such as “Product Group Image”, it will return an array, need

Related articles

How to configure Docker reverse proxy to display multiple independent websites for AnQiCMS multi-site feature?

AnQiCMS (AnQiCMS) is favored by many website operators for its efficient and flexible content management capabilities.Especially its powerful multi-site management feature, combined with Docker containerization technology and reverse proxy, allows you to easily set up and manage multiple independent websites on the same server, greatly enhancing operational efficiency and reducing maintenance costs. ### Discover the charm of multiple sites Imagine that you may have several different brands, aimed at different audiences, or serving different regions, but their content update and management processes are roughly the same.

2025-11-07

How to automatically convert URLs to clickable links in AnQiCMS templates using the `urlize` filter?

In website content management, we often need to display external links in articles, comments, or introductions.Manually adding the `<a>` tag to each URL is not only cumbersome but also prone to errors, especially when dealing with large amounts of user-generated content or importing data from other sources.Fortunately, AnQiCMS provides a very practical template filter——`urlize`, which can automatically identify URLs and email addresses in text and convert them into clickable links, greatly simplifying the work of content managers.

2025-11-07

How to set the website logo and filing number of AnQiCMS so that it can be displayed correctly on the front-end page?

During the process of building a website, the brand identity (Logo) and the necessary compliance information (record number) are indispensable elements.They can not only enhance the professionalism and credibility of the website, but also provide clear guidance to users.AnQiCMS is an efficient content management system that provides an intuitive and convenient way to set these information and ensures that they are displayed correctly on the website front-end page. Next, we will learn how to set the website logo and filing number in AnQiCMS in detail.

2025-11-07

How to display user details such as avatar and username in AnQiCMS templates?

In AnQiCMS, flexibly displaying users' detailed information in templates, such as avatars and usernames, is an important step to achieve personalization and enhance website interaction.AnQiCMS's powerful template engine provides an intuitive and efficient way to integrate these data. ### Understanding the Data Calling Mechanism of AnQiCMS Template AnQiCMS template system uses a syntax style similar to Django, which makes template writing both intuitive and powerful.The essence lies in using specific template tags to call back-end data.

2025-11-07

How to customize templates in AnQiCMS to change the overall visual style and layout of the website?

In this era that emphasizes brand and user experience, the visual style and layout of a website is the key to its successful operation.AnQiCMS (AnQiCMS) understands this point and therefore provides a highly flexible template customization feature, allowing users without a strong development background to create websites that meet their unique needs with a personalized touch.If you are considering changing the overall style of the website or want to design a dedicated layout for specific content, it will be very helpful to understand how to customize templates in AnQiCMS.

2025-11-07

Where should the AnQiCMS template files be stored, and what file extensions are supported?

AnQiCMS is designed very clearly and flexibly in template file management, aiming to allow users to customize the appearance and functions of the website efficiently.If you are using AnQiCMS to build or maintain a website, understanding the location of template files and supported suffixes is the foundation for front-end development and customization.

2025-11-07

How to use Django template engine syntax to efficiently display various dynamic content in AnQiCMS?

In AnQi CMS, you will find that the built-in Django template engine syntax is an extremely powerful and flexible tool, which can help you efficiently convert backend data into dynamic and lively content on the frontend page.Master this syntax, and you'll not only be able to display basic text and images, but also build complex, interactive dynamic pages, making your website vibrant.The template syntax design of Anqi CMS is very intuitive, it draws on the characteristics of the Django template engine and integrates the concise and efficient Go language.

2025-11-07

How to use `if-else` conditional tags to control the display logic of content in AnQiCMS templates?

In AnQiCMS templates, make good use of the `if-else` conditional judgment tag to make content display more intelligent In website content operation, we often need to display different content or styles according to different conditions.For example, when the article list is empty, display 'No content', when an article is in the recommended state, add a 'HOT' mark, or add a special style to the first item in the loop.

2025-11-07