How to retrieve and display specific fields (such as title, content, image) of the document detail page using the `archiveDetail` tag?

Calendar 👁️ 63

In the Anqi CMS-built website, each document detail page is the key to displaying core content and attracting visitors to stay. To ensure that these pages can efficiently and flexibly present important information such as article titles, content, and images, understanding and utilizing it well is necessary.archiveDetailTags are particularly important. They are the powerful tools that allow you to accurately locate and flexibly display these core data.

MasterarchiveDetailTags: Accurate location and display of document details content

When you create an article or product detail page in AnQiCMS,archiveDetailThe tag is the key information you extract from the database for the current page or specified document.This tag's design concept is simple and powerful, allowing you to easily present backend data on the frontend template.

archiveDetailusage

In most cases, when you are editing a document detail page (for example,article/detail.htmlorproduct/detail.html),archiveDetailThe tag automatically identifies and retrieves the document data corresponding to the current page. Its most common usage is to directly passnameThe attribute specifies the document field you want to retrieve.

For example, to display the title of the current document, you can use the following syntax:

<div>文档标题:{% archiveDetail with name="Title" %}</div>

In addition, you can also do it more directly through the template of the document details page,{{archive.字段名称}}such a form to access the various properties of the current document, for example{{archive.Title}}. This way is more concise and suitable for directly obtaining the document information of the current page.

If you need to display on a non-document detail page (such as a block on the homepage) or specify the details of a particular document, archiveDetailLabels also providedidortokenParameters, allowing you to accurately retrieve data based on the document ID or URL alias:

{# 获取ID为1的文档标题 #}
<div>指定文档标题:{% archiveDetail with name="Title" id="1" %}</div>
{# 获取URL别名为"about-us"的文档内容 #}
<div>指定文档内容:{% archiveDetail with name="Content" token="about-us" %}</div>

Get and display core information

Next, let's see how to use itarchiveDetailLabel to retrieve and display common fields of the document detail page:

1. Document title (Title)

Obtaining the document title is very direct, it is usually one of the most prominent elements on the page:

<h1>{% archiveDetail with name="Title" %}</h1>
{# 或者更简洁地 #}
<h1>{{archive.Title}}</h1>

2. Document content (Content)

The document content is usually the longest part on the page, carrying the main information. Since the document content may contain HTML tags (such as paragraphs, links, images, etc.), you need to use|safefilter.

<div>
    {%- archiveDetail articleContent with name="Content" %}
    {{articleContent|safe}}
</div>
{# 或者更简洁地 #}
<div>{{archive.Content|safe}}</div>

If your backend has enabled the Markdown editor and you want the front-end content to be automatically rendered as HTML, you canarchiveDetailthe tag withrender=trueparameters:

{# 启用Markdown渲染 #}
<div>
    {%- archiveDetail articleContent with name="Content" render=true %}
    {{articleContent|safe}}
</div>

In addition, if you want the images in the document content to support lazy loading, you can combine the requirements of the front-end lazy loading library inarchiveDetailthe taglazy="data-src"(According to the actual requirements of your lazy loading librarydata-srcAdjust the attribute name):

{# 启用图片懒加载,将图片src属性替换为data-src #}
<div>
    {%- archiveDetail articleContent with name="Content" lazy="data-src" %}
    {{articleContent|safe}}
</div>

3. Document image (Logo,Thumb,Images)

AnQi CMS provides various image fields to meet different display needs:

  • Logo: Usually used to get the main cover image or large image of the document.
    
    <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
    
  • ThumbUsed to retrieve the document thumbnail, which is usually a small-size image cropped or compressed by the system.
    
    <img src="{% archiveDetail with name="Thumb" %}" alt="{% archiveDetail with name="Title" %}" />
    
  • ImagesIf the document contains a set of images (such as a carousel on a product details page),ImagesIt will return an array of image URLs. You need to usefora loop to iterate and display these images:
    
    <div>
        {% archiveDetail archiveImages with name="Images" %}
        {% for item in archiveImages %}
            <img src="{{item}}" alt="文档图片" />
        {% endfor %}
    </div>
    

4. Other commonly used fields

In addition to titles, contents, and images,archiveDetailtags can also obtain a lot of other useful document information:

  • Document description (Description): It is usually the introduction or summary of the article.
    
    <meta name="description" content="{% archiveDetail with name="Description" %}">
    
  • Document link (Link): The current document's URL address.
    
    <a href="{% archiveDetail with name="Link" %}">查看详情</a>
    
  • Views (Views): Shows the number of times the document has been read or accessed.
    
    <span>浏览量:{% archiveDetail with name="Views" %}</span>
    
  • Publish time (CreatedTime)andUpdate time (UpdatedTime): These are timestamps that need to be matched withstampToDateLabel formatting is displayed.
    
    <span>发布日期:{{ stampToDate(archive.CreatedTime, "2006年01月02日") }}</span>
    <span>更新时间:{{ stampToDate(archive.UpdatedTime, "2006-01-02 15:04:05") }}</span>
    
  • Document classification (Category): Retrieve the detailed information of the current document category, which is very useful when displaying breadcrumb navigation or related categories.
    
    {% archiveDetail currentCategory with name="Category" %}
    <a href="{{ currentCategory.Link }}">{{ currentCategory.Title }}</a>
    {% endarchiveDetail %}
    
  • Custom field: AnQiCMS allows you to add custom fields to content models. If your document model defines such custom fields, you can directly access them through theauthor/sourcecustom fields, you can directly access them throughnameproperty to get them:
    
    <span>作者:{% archiveDetail with name="author" %}</span>
    
    If you want to iterate over all custom fields, you can usearchiveParamsTags:
    
    {% archiveParams params %}
    <div>
        {% for item in params %}
            <span>{{item.Name}}:</span>
            <span>{{item.Value}}</span>
        {% endfor %}
    </div>
    {% endarchiveParams %}
    

Example of practical application scenarios

Let's look at the structure of a typical article detail page, how toarchiveDetailand related tags to build:

”`twig {% extends ‘base.html’ %} {# Inherit base template #}

{% block content %}

{# 获取并显示文档标题 #}
<h1>{% archiveDetail with name="Title" %}</h1>

<div class="meta-info">
    {# 显示文档分类 #}
    {% archiveDetail currentCategory with name="Category" %}
    <span>分类:<a href="{{ currentCategory.Link }}">{{ currentCategory.Title }}</a></span>
    {% endarchiveDetail %}

    {# 显示发布时间 #}
    <span>发布日期:{{ stampToDate(archive.CreatedTime, "2006

Related articles

How to create and display independent pages such as 'About Us' and 'Contact Us' in a single-page management?

In website operation, independent pages like "About Us" and "Contact Us" are essential basic content.They not only help visitors quickly understand the company and provide contact information, but are also a key window for building trust and showcasing the brand image.AnQiCMS (AnQiCMS) provides us with an intuitive and powerful single-page management function, making it easy and efficient to create and maintain these pages. Next, we will explore how to create, display these independent pages, and integrate them into the website navigation in Anqi CMS.### Step 1

2025-11-07

How to manage image resources and control their display in content (such as Webp, automatic compression, thumbnails)?

In website operation, images are indispensable elements that attract users and convey information.However, managing and optimizing these image resources is often a headache, as it directly affects the website's loading speed, user experience, and even the search engine optimization (SEO) effect.Fortunately, AnQiCMS provides a series of powerful and flexible features for image management, allowing you to easily cope with these challenges.Why is image management so important? Imagine a user opening your website and being unable to see the full content due to slow image loading

2025-11-07

How does mobile end address configuration affect mobile users' access and display of website content?

With the popularity of smartphones, mobile devices have become the mainstream way for users to access websites.The performance of the website on mobile directly affects user experience and search engine rankings.In Anqi CMS, the configuration of the mobile end address is the key link to ensure that the website can provide mobile users with a **good access experience.Flexible and diverse options are provided by Anqi CMS for mobile adaptation, mainly including adaptive, code adaptation, and PC+mobile independent site modes.When we choose the adaptive or code adaptation mode, the website will share a set of URL addresses on both PC and mobile ends

2025-11-07

How do website logo, filing number, copyright information and other global settings affect the display of the website footer and header?

Build a professional and trustworthy website often requires those seemingly trivial but crucial global settings.This information is like the "business card" and "background" of the website, silently conveying the brand's image, credibility, and compliance at the first time of user access.AnQiCMS (AnQiCMS) took this into consideration from the beginning of its design, allowing website Logo, filing number, copyright information, and other core global settings to be conveniently and efficiently managed and displayed in the header and footer of the website, thereby shaping your unique website image.At the Anqi CMS backend

2025-11-07

How to implement pagination for document list, related documents, and search results using the `archiveList` tag?

Manage website content in Anqi CMS, whether it is blog articles, product displays, or news information, efficient list display is indispensable.When the amount of content gradually increases, how to elegantly present a large number of documents and ensure that users can easily browse and search has become a key point that operators need to pay attention to.At this time, the `archiveList` tag and its accompanying pagination feature have become a powerful tool in our hands, it can not only implement pagination for conventional document lists, but also be flexibly applied to the display of related documents and search results.### Pagination display of document list Imagine

2025-11-07

How to get and display the title, description, thumbnail, and associated content of the `categoryDetail` tag?

Manage and display website content in Anqi CMS, the `categoryDetail` tag plays a crucial role.It is like the conductor of your website content display, able to accurately obtain and present all the detailed information of a specific category, whether it is the title, description, thumbnail, or deeper related content, it can help you a lot. ### The core function of the `categoryDetail` tag In simple terms, the mission of the `categoryDetail` tag is to obtain detailed data for a single category.

2025-11-07

How to get and display the title, content, and image of a single page using the `pageDetail` tag?

## AnQi CMS `pageDetail` tag: Easily obtain and display single page information Single pages (such as "About Us", "Contact Us", "Terms of Service", etc.) play an indispensable role in website content management.They usually carry stable, core information that does not need to be updated as frequently as articles or products.AnQi CMS provides an efficient and flexible tool for displaying this type of page - the `pageDetail` tag.Mastering the use of this tag will allow you to be proficient in template development, easily presenting beautifully designed single-page content

2025-11-07

How to dynamically generate the page Title, Keywords, and Description using the `tdk` tag to optimize SEO display?

In website operations, Search Engine Optimization (SEO) is a key link to improve website visibility and attract natural traffic.Among them, the page's `Title` (title), `Keywords` (keywords), and `Description` (description), abbreviated as TDK, are important signals for search engines to understand the content of the page and determine the ranking.An excellent TDK setting can make your website stand out in a sea of information.AnQiCMS (AnQiCMS) fully understands the importance of TDK and has integrated powerful TDK management functions into the system design from the very beginning

2025-11-07