How to use the `archiveDetail` tag to get detailed information of a specific document?

As an experienced website operations expert, I know that content is the soul of the website, and how to efficiently and accurately present this content is an indispensable part of our daily work.In such a powerful content management system as AnQiCMS, making good use of the provided template tags can greatly improve our content operation efficiency.archiveDetailThis tag is the core tool for obtaining detailed information about specific documents, whether you are a content editor, front-end developer, or website administrator, mastering it will greatly facilitate your work.

archiveDetailLabel: Core Tool for Precisely Gaining Document Details

Imagine when a user clicks on an article or product detail page on a website, they expect to see complete, detailed and well-formatted information. AndarchiveDetailThe label, which is designed to achieve this goal for AnQiCMS.Its core function is to help us accurately extract and display all relevant information of a single document (which can be an article, product, or any specific entry under any content model).This means that we can not only obtain the title, content, and publication time of the document, but also retrieve its category, cover image, and any additional fields customized in the background, making each detail page full of vitality.

Master the basic syntax: Make document information as you wish

archiveDetailThe use of tags is very intuitive, and its basic syntax is usually presented as:

{% archiveDetail 变量名称 with name="字段名称" id="文档ID" %}

Let's analyze the key parameters one by one:

  • 变量名称This is not required, but strongly recommended.It allows you to store the data you obtain in a custom variable, which is convenient for repeating references in subsequent template code, making the code structure clearer.If you choose not to define a variable name, the label will directly output the value of the field.
  • name="字段名称"This isarchiveDetailThe core label, it specifies the specific document field you want to retrieve. AnQiCMS has a variety of fields, such asTitle(Document Title),Content(Document content),Link(Document link) etc., we will introduce some common fields in detail later.
  • id="文档ID"ortoken="文档URL别名"These two parameters are used to specify the document you want to retrieve accurately. Usually on the document detail page, AnQiCMS automatically recognizes the document ID of the current page, so most of the time you can omit these two parameters,archiveDetailIt intelligently retrieves information about the document currently being accessed. But when you need to display the details of a specific document on other pages (such as the homepage, sidebar),idortokenit comes in handy.
  • siteId="站点ID": AnQiCMS supports multi-site management. If you need to retrieve document information from another site, you can specify the ID of the target site through this parameter.This is very useful when building cross-site content aggregation or display.

Common document information fields and their application examples

archiveDetailTags provide rich fields, allowing us to display document information in multiple dimensions. The following are some of the most commonly used fields and their application scenarios in actual operation:

1. Core Information: Title and Link

  • Title(Document Title): This is the soul of the document, usually used as the page main title (H1).
    
    <h1>{% archiveDetail with name="Title" %}</h1>
    
  • Link(Document Link)Used to construct the document detail page URL, ensuring smooth access for users.
    
    <a href="{% archiveDetail with name="Link" %}">阅读更多</a>
    

2. Content Display: Smart processing of rich text and Markdown.

  • Content(Document Content): This is the main body of the document, which usually contains a large amount of text, images, and HTML structures. AnQiCMS providesContenta very flexible handling method for fields:

    • |safeFilter: Due toContentMay contain HTML code, output directly may be escaped. Add|safeFilter, can ensure that HTML content is correctly parsed and rendered.
    • lazy="data-src"Parameter: To optimize page loading speed, we can work with front-end lazy loading libraries, by this parameter to<img>label'ssrcproperties todata-srcor other custom properties.
    • render=true/falseParameterIf your content is in Markdown format (the Markdown editor is enabled on the backend),render=trueit will be automatically rendered as HTML. Otherwise,render=falseit will not be rendered.
    {# 结合safe和图片懒加载 #}
    <div class="article-content">
        {% archiveDetail articleContent with name="Content" lazy="data-src" %}
        {{ articleContent|safe }}
    </div>
    
    
    {# 渲染Markdown内容 #}
    <div class="markdown-body">
        {% archiveDetail articleContent with name="Content" render=true %}
        {{ articleContent|safe }}
    </div>
    

3. Visual Elements: Image Resources and Display

  • Logo(Cover Main Image)/Thumb(Thumbnail)/Images(Group photo): These fields are used to display the visual elements of the document, adding attractiveness to the page.

    {# 展示封面首图 #}
    <img src="{% archiveDetail with name="Logo" %}" alt="{% archiveDetail with name="Title" %}" />
    
    
    {# 展示组图(Images是一个数组,需要循环) #}
    <div class="gallery">
        {% archiveDetail archiveImages with name="Images" %}
        {% for imgUrl in archiveImages %}
            <img src="{{ imgUrl }}" alt="图片描述" />
        {% endfor %}
    </div>
    

4. Metadata and Time: Detailed Content

  • Description(Document Description)/Keywords(Keywords)/Views(Views): These are key information for SEO and user insights.
    
    <meta name="description" content="{% archiveDetail with name="Description" %}">
    <span>浏览量:{% archiveDetail with name="Views" %}</span>
    
  • CreatedTime(Creation Time)/UpdatedTime(Update Time): Data in timestamp format needs to be processed throughstampToDatea function to be displayed in a human-readable format.
    
    <span>发布于:{{ stampToDate(archive.CreatedTime, "2006年01月02日 15:04") }}</span>
    

5. Attribute Information: Classification and Model