How to retrieve and display the detailed information of a single document, including its custom fields, using the `archiveDetail` tag?

Calendar 👁️ 84

In a content management system, effectively displaying detailed information of a single document is one of the core requirements.Whether it is news articles, product introductions, or service descriptions, users always hope to have a direct and comprehensive understanding of the specific content of each item.AnQiCMS (AnQiCMS) provides powerfularchiveDetailLabels, allowing you to easily retrieve and display all information about a single document, even including your custom exclusive fields.

Get the core information of the document:archiveDetailusage

archiveDetailTags are tools used in Anqi CMS templates to accurately extract detailed data of a single document. Its basic syntax is{% archiveDetail 变量名称 with name="字段名称" id="文档ID" %}. Here,变量名称is an optional alias used to refer to the obtained data in subsequent template code;nameThe parameter specifies the specific document field you want to retrieve;idThe parameter allows you to specify the document to retrieve for a specific ID. Of course, if you are on the document detail page (such asdetail.htmlorarchive/detail.html), it is usually not necessary to provideidParameters, the system will default to retrieving the document information of the current page. In addition, you can also specify the document's URL alias throughtokenparameters to obtain its details.

This tag can help you extract various built-in fields of the document, such as:

  • Id: The unique identifier of the document.
  • Title: The title of the document.
  • Link: The access link of the document.
  • Description: A brief description or summary of the document.
  • Views: Document views.
  • Logo: The main cover image of the document.
  • Thumb: The thumbnail of the document cover.
  • CategoryId: The ID of the category to which the document belongs.

For example, if you want to display the document title on the detail page, you can write it like this: <h1>{% archiveDetail with name="Title" %}</h1>

If you need to get the link of the document with a specified ID, you can do it like this:<a href="{% archiveDetail with name="Link" id="10" %}">查看文档10</a>

It is particularly noteworthy thatContentThe field carries the main content of the document, usually containing rich text and graphic information, even in HTML format. When you need to display this content, please be sure to use|safeA filter to ensure that HTML code is parsed correctly and not displayed as plain text:<div>{% archiveDetail content with name="Content" %}{{content|safe}}</div>If your content is in Markdown format and you want it to be rendered as HTML on the front end, you can useContentfield'sarchiveDetailthe tag withrender=trueparameters:<div>{% archiveDetail content with name="Content" render=true %}{{content|safe}}</div>Additionally, for content with many images, you can also make use oflazyThe parameter specifies the lazy loading attribute of the image, for examplelazy="data-src"so that your front-end lazy loading script can work properly.

For date and time fields such asCreatedTime(creation time) andUpdatedTime(update time),archiveDetailthe tag also provides convenient features forformatParameters to directly format the output, saving the manual stepsstampToDateThe steps of the tag:<span>发布日期:{% archiveDetail with name="CreatedTime" format="2006年01月02日" %}</span>

Extended usage: flexible display of custom fields

The strength of AnQi CMS lies in its flexible content model design, which allows you to customize document fields according to your business needs. These custom fields can also be accessed througharchiveDetailEasily retrieve and display tags.

Assuming you have defined a custom field namedpricein the content model. You can directly get its value throughnameparameter:<span>产品价格:{% archiveDetail with name="price" %} 元</span>

If you are unsure about which custom fields are in the document, or if you want to dynamically display all custom fields,archiveParamsThe tag comes into play. It allows you to traverse all the additional parameters of the document. Usually, you would want these parameters to be displayed in the order of the backend settings, at which point you can usesorted=trueParameter (This is the default behavior):

{% archiveParams params %}
<ul class="custom-fields">
    {% for item in params %}
    <li>
        <strong>{{item.Name}}:</strong>
        <span>{{item.Value}}</span>
    </li>
    {% endfor %}
</ul>
{% endarchiveParams %}

In this way, you can build a universal template that automatically adapts to the display of custom fields under different content models.

Practical Application: Building articles and product detail pages

Combine the above tags and you can easily build a well-functioning document detail page

Article detail page example:In a typical article detail page, you may need to display the title, category, publication time, tags, and article content.

<article>
    <h1>{% archiveDetail with name="Title" %}</h1>
    <div class="meta-info">
        <span>分类:<a href="{% categoryDetail with name='Link' id=archive.CategoryId %}">{% categoryDetail with name='Title' id=archive.CategoryId %}</a></span>
        <span>发布于:{% archiveDetail with name="CreatedTime" format="2006-01-02" %}</span>
        <span>阅读量:{% archiveDetail with name="Views" %}</span>
        <div class="tags">标签:
            {% tagList tags with itemId=archive.Id limit="5" %}
            {% for tag in tags %}
                <a href="{{tag.Link}}">{{tag.Title}}</a>
            {% endfor %}
            {% endtagList %}
        </div>
    </div>
    <div class="article-content">
        {% archiveDetail content with name="Content" render=true %}{{content|safe}}</div>
</article>

Product detail page example:For product detail pages, displaying images, names, custom parameters (such as brand, model), and detailed descriptions is a common layout.

<div class="product-detail">
    <div class="product-gallery">
        <img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %}" />
        {# 如果有自定义的图片组字段 'product_images' #}
        {% archiveDetail productImages with name="product_images" %}
        <div class="thumbnail-list">
          {% for img in productImages %}
          <img src="{{img}}" alt="产品图" />
          {% endfor %}
        </div>
        {% endarchiveDetail %}
    </div>
    <div class="product-info">
        <h1>{% archiveDetail with name="Title" %}</h1>
        <p class="description">{% archiveDetail with name="Description" %}</p>
        <div class="product-params">
            {% archiveParams params %}
            {% for item in params %}
            <p><strong>{{item.Name}}:</strong> {{item.Value}}</p>
            {% endfor %}
            {% endarchiveParams %}
        </div>
        <a href="tel:{% contact with name='Cellphone' %}" class="contact-btn">立即咨询:{% contact with name="Cellphone" %}</a>
    </div>
    <div class="product-full-content">
        <h2>产品详情</h2>
        {% archiveDetail content with name="Content" render=true %}{{content|safe}}
    </div>
</div>

Tip

In template development, when you are sure that the current page context is already a document object (for example, indetail.htmlorarchive/detail.html), in addition to using{% archiveDetail with name="字段名称" %}tag, you can also directly through{{archive.字段名}}In a way to obtain the document field, which is usually more concise and convenient. For example,<h1>{{archive.Title}}</h1>It can directly display the document title.

In short,archiveDetailTags provide a flexible and powerful way to display detailed information about a single document in AnQi CMS, including all custom fields,

Related articles

How does the `archiveList` tag control the display quantity, sorting method, and pagination logic of the document list?

In AnQi CMS, the `archiveList` tag is undoubtedly a core tool for content display, providing great flexibility and control for the website's content list.Whether you want to display the latest articles on the homepage or implement complex filtering and pagination on the category page, `archiveList` can help us present content accurately through its rich parameter configuration.Next, let's delve into how to use this tag to control the display quantity, sorting method, and the implementation of exquisite pagination logic of the document list.### Control Document Display Quantity

2025-11-08

How to use the various tags built into AnQiCMS to retrieve and display the system information, content list, and details of the website?

How to efficiently display various information when building and managing a website is the key to user experience and operational efficiency.AnQiCMS With its flexible and powerful template tag system, enables content creators and website operators to easily control the acquisition, display, and personalized customization of website content without a deep programming background.This article will delve into the rich tags built into AnQiCMS, showing you how to cleverly use them to retrieve and display the system information, content list, and diverse content of detail pages of the website.Understanding AnQiCMS

2025-11-08

How to customize independent display templates for single pages such as 'About Us' to meet specific display requirements?

In Anqi CMS, in order to make single pages like "About Us" and "Contact Us" have unique display effects, rather than following the unified page layout of the website, we can customize independent display templates for them.This customized capability is a reflection of the flexibility of Anqi CMS, which can help us better shape our brand image, or provide a more suitable display form for specific content.### Overview of AnQi CMS Template Mechanism The AnQi CMS template system is designed to be very intuitive and powerful, based on syntax similar to the Django template engine, which separates the presentation of content from logical control.

2025-11-08

How does AnQiCMS's flat file organization pattern simplify template management and optimize the content display process?

In website operation, template management is a key link that balances efficiency and experience.A well-designed, easy-to-maintain template system that can greatly enhance the speed of website content publishing and the flexibility of page updates.AnQiCMS provides unique solutions in this field, especially its 'flat file organization mode', which brings practical convenience to users in simplifying template management and optimizing the content display process.### Say goodbye to layered nesting: The charm of AnQiCMS flat file organization In many traditional content management systems, template files are often buried deep in a multi-level directory structure

2025-11-08

How are the `categoryList` and `categoryDetail` tags used to build and display the hierarchical structure of the website?

In Anqi CMS, the classification hierarchy of the website is the core of content organization, which not only affects the user's browsing experience, but is also an important link in search engine optimization.To effectively build and display these classification structures, we mainly rely on two powerful template tags: `categoryList` and `categoryDetail`.They work together, allowing you to flexibly present clear and organized content categories on the website front-end.### Build the category list: `categoryList` tag `categoryList`

2025-11-08

How to manage and display independent single-page content for the `pageList` and `pageDetail` tags?

In website operation, in addition to dynamically updated articles or product lists, we often need to display some relatively fixed and independent content pages, such as "About Us", "Contact Information", "Privacy Policy" or "Service Introduction" and so on.These pages are usually called "single-page content". AnQiCMS provides us with powerful and flexible tools for managing and displaying these pages, especially the core tags `pageList` and `pageDetail`.### Single Page Content: The Foundation of a Website Single page content is an indispensable part of a website

2025-11-08

How to implement content aggregation and thematic display based on `tagList` and `tagDetail` tags?

In content management and website operations, how to efficiently organize and display content is the key to improving user experience and SEO performance.AnQiCMS provides powerful tag features, with the `tagList` and `tagDetail` template tags, it is easy to implement content aggregation based on tags and thematic display, bringing more flexible classification and richer navigation experience to the website.### The role of tags in content aggregation Tags are an important way to organize content in a content management system

2025-11-08

How to generate and control the pagination display effect of the `pagination` tag?

In website operation, when the amount of content is large, how to efficiently and beautifully display these contents while ensuring that users can browse conveniently is the key to improving user experience.If you dump all the content on the same page, not only will it load slowly, but it will also deter visitors.At this moment, content pagination becomes particularly important. It breaks massive information into several pieces, which not only reduces the burden of page loading but also allows users to explore the content they are interested in step by step at their own pace.AnQiCMS provides a powerful and flexible `pagination` tag

2025-11-08