How do custom fields in the Anqi CMS content model affect the display of document detail pages?

Calendar 👁️ 65

In AnQiCMS, the content model and custom fields are the core functions to enhance the flexibility and diversity of website content management.They make websites no longer limited to the traditional 'title+content' mode, but can display more personalized and structured information according to different business needs.How do these meticulously configured custom fields in the background affect the display of our website's document detail page?

Understanding the association between the content model and custom fields

To explore how custom fields affect the document detail page, we first need to understand the "content model" in AnQiCMS.In simple terms, the content model is the 'skeleton' or 'blueprint' of various types of content on your website.For example, your website may need to publish common 'articles', or display specific 'product' information, or promote an 'event'.These different types of content have entirely different information structures.The article may have an author, source, and publication date; products should have price, inventory, product parameters, and multiple image displays, etc.

The flexible content model feature of AnQiCMS is exactly to solve this pain point.It allows you to create or modify content models based on actual business needs and add exclusive "custom fields" to them.These custom fields are like information slots on the content model, and you can define them as needed.In the background "Content Management" under the "Content Model" settings, you can add custom fields for each model and set the "parameter name" (display name on the front-end), "field name used in template" (variable name), and "field type".

The field type is very critical, as it determines what type of data the field can store and also indirectly affects the display style on the front end.AnQiCMS supports various field types such as single-line text (suitable for names of authors, product models, etc.), numbers (such as price, inventory), multi-line text (such as product descriptions), single selection, multiple selection, drop-down selection (suitable for properties with preset options, such as color, size), as well as images and files.These different types provide your content with great structural capabilities.

The custom field is displayed on the document detail page

When you add or edit documents in the background, once you have selected a category under a content model, you will find that in addition to the common fields such as document title and content, a foldable box named "Other parameters" will appear at the bottom of the page.Here is displayed the entire set of custom fields you have defined for the content model.You can enter the corresponding content according to these field prompts, such as filling in the price, brand for products, and adding the author, source for articles, etc.

This data filled in the background needs to be displayed on the front-end document detail page.AnQiCMS uses the Django template engine syntax, allowing you to flexibly control the display of content.In the template file corresponding to the document details page (usually{模型table}/detail.htmlIn or custom document template),you have multiple ways to call these custom fields:

  1. Call by variable name:For simple, definite custom fields, such as the field you defined as a call field forauthora single-line text field, it can be used directly in the template{{archive.author}}This displays its content. This method is concise and clear, suitable for cases where you clearly know the field name and the field content does not require special processing.

  2. UsearchiveDetailTag retrieval: archiveDetailIs a powerful tag provided by AnQiCMS, which can not only get the built-in fields of the document, but also get custom fields by name. For example, if your product model has a field calledpriceThe numeric field, you can use{% archiveDetail with name="price" %}To retrieve and display the price. This method is particularly suitable for when you want to obtain and display a custom field value individually in a template, and may need to perform additional processing on it.

  3. UsearchiveParamsTag to loop and retrieve all custom fields:In some cases, you may want to dynamically list all the custom fields of a document, for example, to display a complete list of 'product parameters' on a product detail page. At this point,archiveParamsThe tag is very convenient. It will return an array object containing all custom fields, and you canforloop through this array to display the names and values of each field:

    {% archiveParams params %}
        {% for item in params %}
        <div>
            <span>{{item.Name}}:</span>
            <span>{{item.Value}}</span>
        </div>
        {% endfor %}
    {% endarchiveParams %}
    

    This method is very flexible, even if you delete or add custom fields in the background later, the front-end page can automatically adapt without modifying the template code.

Considerations for displaying different custom field types

Different types of custom fields, which may require different handling when displayed on the front end:

  • Single-line text, numbers, radio buttons/dropdown selections:This field's content is usually plain text or numbers and can be directly translated{{变量名}}Output.
  • Multiline text or rich text (for example, when the Markdown editor is turned on):These fields may contain HTML tags or Markdown syntax. To ensure that this content is parsed and rendered correctly by the browser rather than displayed as plain text, you need to use|safeFilter. If your multi-line text field stores Markdown formatted content and you want it to be automatically converted to HTML on the front end, in addition to enabling the Markdown editor on the back end, you also need to use the template.|render|safea filter such as{{archive.introduction|render|safe}}.
  • Image/Album Field:If you have customized a field for uploading a single image, its value will be the image URL. You can use it directly in the template.<img>Tag reference:<img src="{{archive.custom_image_field}}" alt="描述" />If the custom field allows uploading multiple images (a set of images), then the value of this field is usually an array of image URLs, and you need to usefora loop to traverse and display each image.

Understand the display effect through actual cases

Imagine that you are building a product display website, and the product detail page needs to show the detailed parameters such as "brand", "model", "power", "applicable area", and so on.Through the AnQiCMS content model, you can add these custom fields to the 'product model', the type may be single-line text, number, or dropdown selection.

When the user visits a product detail page, the template organizes the content this way: Firstly, use<h1>{{archive.Title}}</h1>Display the product name. Next, througharchiveDetailGet the product image:<img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %}" />. Then, the most exciting part comes—the product parameter list. You can usearchiveParamstags to traverse and display all custom parameters:

<div>
    <h3>产品参数:</h3>
    {% archiveParams params %}
        {% for item in params %}
        <div>
            <span>{{item.Name}}:</span>
            <span>{{item.Value}}</span>
        </div>
        {% endfor %}
    {% endarchiveParams %}
</div>

In this way, no matter how many parameters you add to the product in the background, the front-end page can automatically and elegantly display them without having to modify the template code each time. If the product description is a rich text field, you would use<div>{% archiveDetail with name="Description" %}{{archive.Description|safe}}</div>Make sure that its HTML content is parsed correctly.

By this method, AnQiCMS's custom fields greatly enhance the richness and management efficiency of content, allowing you to easily build clear, comprehensive, and highly personalized document detail pages.It gives content operators powerful control over information display, making your website content no longer monotonous.


Frequently Asked Questions (FAQ)

Q1: Why is a multi-line text custom field displayed as plain text with HTML tags on the detail page?A1: This is because the Django template engine defaults to escaping output content to prevent XSS attacks. If your multi-line text field content is HTML code edited by a rich text editor, or if you want Markdown content to be converted to HTML for display, you need to use this field when calling it in the template|safeFilter, for example{{archive.your_custom_field|safe}}If the content is in Markdown format, then you need to use|render|safeFor example{{archive.your_markdown_field|render|safe}}.

Q2: I created a custom 'product album' field (multiple images uploaded), how should I display multiple images on the detail page?A2: When the custom field is set to

Related articles

How to set up independent Banner images or thumbnails for document categories to be displayed on the front page?

In AnQiCMS, setting up an independent Banner image or thumbnail for document categories can greatly enhance the visual appeal and user experience of the website, making each category have a unique brand identity.In fact, AnQiCMS provides very intuitive and flexible functions in this aspect, you can easily set up a few steps to make these custom images beautifully appear on the front page. ### One, configure exclusive visual elements for categories in the background Firstly, we need to upload and set these unique images for your document categories in the AnQiCMS background.

2025-11-07

How do the SEO title and keywords of the document category affect the search results display of the category page?

For website content operation, the category page is an important entry for users to discover and for search engines to crawl the website content.A meticulously optimized category page, which not only improves user experience but also significantly affects its performance in search engine results.In AnQiCMS (AnQiCMS), the SEO title and keywords of the document category are key factors affecting this performance.

2025-11-07

How does AnQi CMS handle documents that have not uploaded thumbnails, such as displaying default thumbnails?

In website content operation, the visual presentation of content is often the key to attracting readers' attention, and thumbnails play an indispensable role in it.Imagine when you publish a fantastic document but inadvertently forget to upload the thumbnail, resulting in blank or broken icons on the page, which undoubtedly affects the user experience and the professional image of the website.How does AnQiCMS (AnQiCMS) cleverly deal with this situation to ensure that the website always maintains good visual consistency?

2025-11-07

How to set up a timed publishing feature to control the online display time of documents?

In content operation, the timing of content release is often a key factor in determining its communication effect.In order to seize specific marketing opportunities, maintain the rhythm of daily updates, or prepare holiday content in advance, a flexible scheduling publication feature can greatly enhance operational efficiency.AnQiCMS (AnQiCMS) knows this well and has specially provided a powerful scheduled publishing function to allow you to easily plan the content release time and achieve automated operation.This feature is designed to help you reduce cumbersome manual operations, making content operation more strategic and automated.

2025-11-07

How can you filter and display documents of specific content models in the document list?

In website operation, efficiently managing and displaying different types of content is the key to improving user experience and work efficiency.AnQiCMS (AnQiCMS) with its flexible content model design allows you to easily handle various content formats, whether it is articles, product details, or event announcements, and can be managed and displayed in a fine-grained manner. Today, let's delve deeper into how to efficiently filter and display documents of specific content models in AnQiCMS.This can not only help you quickly locate the content you need in the background, but also make the front-end content of your website more accurate and dynamic.

2025-11-07

What impact does the document recycling station function have on users viewing content on the front end?

In daily website operations, operations such as adding, deleting, modifying, and querying content are very common.However, the action of 'deleting' is often accompanied by a hint of hesitation and risk.Our CMS is well-versed in this, providing users with a document recycle bin feature, which is not just a simple 'trash can', but also an important guarantee for your content security and front-end display effect.When you perform a deletion operation on a document, a product detail, or any other entry under any content model in the Anqi CMS backend management system, the most direct impact is that it will immediately disappear from your website's front end.

2025-11-07

How to use Markdown editor to display mathematical formulas and flowcharts in AnQi CMS?

In website operation, we often need to display some content containing mathematical formulas or complex flow charts, which not only makes information delivery more accurate, but also greatly enhances the professionalism and readability of the article.AnQi CMS knows this need, and for this reason, it has built-in support for Markdown editors and combined with external libraries, allowing us to easily present these professional contents in articles.

2025-11-07

How to customize the URL structure of static page rules to enhance user experience and search engine friendliness?

AnQiCMS is a powerful content management system that plays a core role in website operations.Wherein, the flexible configuration of pseudo-static rules is a key factor in improving user experience and search engine friendliness.A clear, concise, and semantically rich URL structure not only makes it easier for visitors to understand the page content but also helps search engines better crawl and index the website, thereby bringing higher visibility and traffic.### The Importance of Understanding URL Structure Before delving into AnQiCMS's pseudo-static rules before

2025-11-07