How to use the `archiveDetail` tag in AnQi CMS to display custom field content of a document?

Calendar 👁️ 71

The AnQi CMS offers a flexible content model design, allowing users to add various custom fields to documents according to their business needs.These custom fields greatly enrich the expression of the website content, whether it is to display product specifications, event details, or additional information of articles, it can be handled with ease.How to cleverly use in the document detail pagearchiveDetailTags to display these valuable custom field contents?

UnderstandingarchiveDetailThe core role of tags

In the AnQi CMS template system,archiveDetailTags are tools used to obtain detailed information about a single document. When you ask a specific article or a product page on a website, it is usually this tag working silently in the background, presenting all the data of the document to the visitor.

The basic usage of this tag is as follows:{% archiveDetail 变量名称 with name="字段名称" id="1" %}.

  • nameThe parameter specifies which field content you want to retrieve, such as the document titleTitleDocument contentContentetc.
  • idThe parameter is used to specify the specific document ID. If you want to get information about a specific document, you can use this parameter.
  • tokenThe parameter is the URL alias of the document, and it can also be used to specify the document.
  • siteIdThis is used in a multi-site environment to specify which site's data to retrieve.

However, most of the time, when you are on the document details page (for example, the file name{模型table}/detail.htmltemplate) is usedarchiveDetailtags, it is usually not necessary to specify explicitlyidortoken. The system will intelligently identify the document on the current page and automatically obtain its detailed data. At this point, you can directly use{{archive.字段名称}}This abbreviated way of calling the standard fields of the document is convenient and intuitive. However, for custom fields, we often rely more onarchiveDetaillabel'snameparameters to accurately obtain.

Display the standard field content of the document

Before we delve into custom fields, let's take a look atarchiveDetailHow to display some common standard fields. These fields are usually present in all documents and do not require additional configuration:

For example, to display the title, description, content, or views of a document, you can do this:

<div>文档标题:{% archiveDetail with name="Title" %}</div>
<div>文档描述:{% archiveDetail with name="Description" %}</div>
<div>文档浏览量:{% archiveDetail with name="Views" %}</div>
<div>文档发布时间:{% archiveDetail with name="CreatedTime" format="2006-01-02" %}</div>
<div>文档内容:{% archiveDetail archiveContent with name="Content" %}{{archiveContent|safe}}</div>

Please note that when displaying the content of a document (Content), we usually use|safeFilter. This is because the document content may contain HTML tags,|safeTell the template engine that this content is safe, does not need to be escaped, and thus ensures that HTML can be rendered normally rather than displayed as plain text.

Core Function: Display Custom Field Content

The strength of Anqi CMS lies in its flexible content model.Under the 'Content Management' menu in the background, you can enter the 'Content Model' settings, create or modify models for different content types (such as articles, products), and add unique custom fields for them.These custom fields can be single-line text, numbers, multi-line text, single selection, multiple selection, or dropdown selection, among other types, to meet various personalized content display needs.

1. Call a Single Custom Field

Once a custom field is defined for the document model in the background, for example, if you add a field named “to the product model产品型号the field name called “product_modelThen, in the product details page, you can access it througharchiveDetaillabel'snameCall it directly via the parameter:

<div>产品型号:{% archiveDetail with name="product_model" %}</div>

If you name the custom fieldauthorYou can retrieve it like this:

<div>文章作者:{% archiveDetail with name="author" %}</div>

This method is simple and direct, suitable for when you know exactly which custom field to display.

2. Loop to display all custom fields

Sometimes, you may want to display all the custom fields of a document in an area without having to list them individually. At this point,archiveParamsthe tag comes into play.archiveParamsThe tag can retrieve all custom parameters of the current document or a specified document and return them as an array.

You can use it like this:

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

In this code block,paramsIt is an array containing multiple objects, each withName(Custom field name) andValue(The value of the field) attribute. ThroughforLoop, you can easily iterate through and display all custom fields of the document. This is particularly convenient for scenarios where you need to dynamically display product parameter lists or detailed properties.

3. Handle special custom fields (such as group images)

If your custom field type is a group image (multiple images), for example, if you define a field named in the backgroundarcimagesThe group image field, then it will be recognized as an array of image URLs in the template. You need to use a loop to display these images one by one:

{% archiveDetail arcimages with name="arcimages" %}
<ul class="arc-images">
  {% for img in arcimages %}
  <li><img src="{{img}}" alt="文档图片" /></li>
  {% endfor %}
</ul>

Here, we first usearchiveDetailthe tag to get the name ofarcimagesAssign the group chart data toarcimagesthe variable, then throughforLoop through this array, embed the URL of each image into<img>in the tag.

Practice case: Combine standard and custom fields to display

To better illustratearchiveDetailThe actual application, let's take a look at how to combine standard fields and custom fields in common articles and product detail pages.

Example of article detail page layout:

Assuming you have a detailed article page, in addition to standard information such as title, content, publication time, and views, you also want to display the "article source" (a custom fieldsource)and "editor" (custom fieldeditor)

<article>
    <h1>{% archiveDetail with name="Title" %}</h1>
    <div>
        <a href="{% categoryDetail with name='Link' %}">{% categoryDetail with name='Title' %}</a>
        <span>发布时间:{% archiveDetail with name="CreatedTime" format="2006-01-02" %}</span>
        <span>浏览量:{% archiveDetail with name="Views" %}°</span>
    </div>
    <div>
        <span>文章来源:{% archiveDetail with name="source" %}</span>
        <span>编辑者:{% archiveDetail with name="editor" %}</span>
    </div>
    <div>
        {%- archiveDetail articleContent with name="Content" %}
        {{articleContent|safe}}
    </div>
</article>

Layout example for product detail page:

For the product detail page, you may need to display product images, product names, product descriptions, and usearchiveParamsDisplay all product specifications dynamically.

<article>
    <div>
        <div>
            <img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %}" />
        </div>
        <div>
            <h1>{% archiveDetail with name="Title" %}</h1>
            <div>产品简介:{% archiveDetail with name="Description" %}</div>
            
            <h3>产品参数:</h3>
            {% archiveParams params %}
            {% for item in params %}
            <div>
                <span>{{item.Name}}:</span>
                <span>{{item.Value}}</span>
            </div>
            {% endfor %}
            {% endarchiveParams %}
            
            <div>
                <a href="tel:{% contact with name='Cellphone' %}" rel="nofollow">电话联系:{% contact with name="Cellphone" %}</a>
            </div>
        </div>
    </div>
    <div>
        <h2>产品详情:</h2>
        <div>
            {%- archiveDetail articleContent with name="Content" %}
            {{articleContent|safe}}
        </div>
    </div>
</article>

Usage tips and precautions.

  • |safeThe filter is indispensable: When your custom field content (especially the 'multiline text' type) may contain HTML tags, be sure to use|safeThe filter, otherwise the HTML code will be escaped into plain text and cannot be rendered normally.
  • Rendering of Markdown content: If your custom field content is entered using a Markdown editor and you want to render it as HTML on the front end, you canarchiveDetailthe tag withrender=trueparameters, for example{% archiveDetail customMarkdownField with name="customMarkdown" render=true %}{{customMarkdownField|safe}}.
  • Field names are strictly case-sensitive:In

Related articles

How to implement conditional judgment and loop traversal in the Anqi CMS template to control content display?

In Anqi CMS, templates are the core of website content presentation, they are not only responsible for the layout and style of content, but also bear the important responsibilities of displaying different content based on different conditions and cyclically presenting data lists.To make your website content more dynamic and interactive, it is particularly important to have a deep understanding of how to implement conditional judgments and loop traversals in templates.The Anqi CMS template engine uses syntax similar to Django, which allows you to quickly get started and flexibly apply it if you are familiar with web development.### Understand AnQiCMS

2025-11-09

How to customize TDK (Title, Description, Keywords) in Anqi CMS to optimize the display of pages in search results?

In website operation, the display effect of the page in search results is crucial for attracting users and increasing traffic.Among them, TDK (Title, Description, Keywords) is the core element that search engines understand the content of the page and decide how to display the page.AnQiCMS (AnQiCMS) provides users with flexible and powerful TDK customization features, helping us refine page optimization, thereby achieving better performance in search results.

2025-11-09

How to independently configure and display the content of each site in the Anqi CMS multi-site environment?

In today's rapidly developing digital age, many businesses and individual operators may not have just one website, but need to manage multiple brand sites, product display pages, or niche field blogs.How to ensure that in such a multi-site environment, each site's content can be independently configured, flexibly displayed, and maintain efficient management, which is a great challenge facing the operators.AnQiCMS (AnQiCMS) takes advantage of its powerful multi-site management function, providing an elegant and practical solution for this.The AnQi CMS was designed from the outset to consider the needs of multi-site operations

2025-11-09

How can Anqi CMS prevent the malicious collection of content and add watermarks to images for display?

Today, with the increasing importance of digital content, protecting original content from malicious collection and misuse has become a challenge for many website operators.Especially images, as the core carrier of visual information, the copyright protection should also not be neglected.AnQi CMS understands these pain points, therefore, in the system design, it especially integrates powerful anti-collection interference codes and image watermark functions, building a solid protective wall for our digital assets.### A clever layout to prevent malicious scraping Malicious scrapers often use automated programs to bulk harvest website content for unauthorized copying and distribution

2025-11-09

How does AnQi CMS truncate long text content and add an ellipsis?

In website content operation, effectively displaying information while maintaining the page's cleanliness and the smoothness of user experience is a crucial link.Especially for long text content, how to truncate the display on the list page or overview section with an ellipsis is a common technique to improve the readability and aesthetics of the website.AnQiCMS (AnQiCMS) is a feature-rich management system that provides a flexible mechanism to meet this requirement at the template layer.

2025-11-09

How to correctly render Markdown content as HTML and display mathematical formulas or flowcharts in Anqi CMS?

In AnQi CMS, using Markdown format to write content not only improves editing efficiency, but also maintains the structuralization and readability of the content.When content involves complex mathematical formulas or a clear flowchart needs to be displayed, the strength of Markdown becomes evident.Our company provides good support for this, let's take a look at how to correctly render and display these advanced contents on the website.### Step 1: Enable Markdown Editor First, make sure that your CMS system has enabled the Markdown editor feature

2025-11-09

How to implement pagination functionality in Anqi CMS and customize the display style of page numbers?

In AnQi CMS, the pagination feature of website content is an indispensable part of improving user experience and optimizing site structure.Whether it is a list of blog articles, product display pages, or other dynamic content, reasonable pagination makes it easier for users to browse a large amount of information and also helps search engines better understand and extract website content.Today, let's delve deeper into how to implement pagination in AnQiCMS and customize the display style of page numbers according to your own needs. ### Why do we need pagination? Imagine that your website has hundreds or even thousands of wonderful articles.If there is no pagination

2025-11-09

How to use the global settings of Anqi CMS to unify the display of copyright information and contact details on the website?

In website operation, copyright statements and contact information are important components for building brand trust, providing user support, and ensuring legal compliance.AnQiCMS (AnQiCMS) fully understands the importance of this information, and therefore provides an intuitive and powerful global setting function, allowing website administrators to uniformly and conveniently control the display of these contents without frequent code modifications.Imagine if your website has hundreds of pages and you need to manually edit each page every time you update the copyright year or customer service phone number, it would be such a繁琐 and error-prone task.

2025-11-09