How to use the `archiveDetail` tag to display images, view counts, and publishing time on the document detail page?

Calendar 👁️ 66

In website operation, the document detail page is the core area to attract users and convey information.A content-rich, intuitive detail page that can significantly enhance user experience and also has a positive impact on search engine optimization (SEO).AnQiCMS provides powerfularchiveDetailLabels, allowing us to easily obtain and display various information of the document, such as images, views, and publication time, etc.

Next, we will explore how to cleverly usearchiveDetailtags to vividly present key information.

Displaying document images: making the content more attractive

Images are an indispensable part of the document content, they can directly convey information and enhance the beauty of the page. AnQiCMS ofarchiveDetailtags provide us with various ways to call pictures:

  • Document cover main image (Logo) and thumbnail (Thumb):These fields are usually used to display the main visual elements of a document, such as the cover image of an article or the main image of a product. They return a single image link.

    <div class="doc-cover-image">
        <img src="{% archiveDetail with name='Logo' %}" alt="{% archiveDetail with name='Title' %} 的封面图" />
    </div>
    {# 如果需要显示缩略图,可以这样调用 #}
    <div class="doc-thumbnail">
        <img src="{% archiveDetail with name='Thumb' %}" alt="{% archiveDetail with name='Title' %} 的缩略图" />
    </div>
    

    InaltEnter the document title in the attribute, it is a good SEO practice.

  • Document Group Images (Images):For scenarios that require displaying multiple images, such as product albums on product detail pages,Imagesthe field will return an array of image link. At this point, we need to combineforLoop tags to iterate and display all images.

    {% archiveDetail docImages with name="Images" %}
    {% if docImages %}
    <div class="product-gallery">
        {% for imageUrl in docImages %}
        <img src="{{ imageUrl }}" alt="产品细节图" loading="lazy" />
        {% endfor %}
    </div>
    {% endif %}
    

    Here we added one.if docImagesThe judgment ensures that the gallery area is rendered only when images exist, to avoid displaying empty content issues.loading="lazy"Properties can help optimize page loading speed.

Traffic statistics: Insight into the popularity of content.

Understanding the document's page views is crucial for content operators, as it helps us judge the popularity of the content and serves as a basis for subsequent optimization strategies. ThrougharchiveDetailThe tag, which shows the document's page views becomes very simple:

<span class="doc-views">阅读量:{% archiveDetail with name='Views' %} 次</span>

Place this code below the document title or in the information summary area, and users can intuitively see the access热度 of this document.

Publishing time: the timeliness and update of the content being conveyed

The document's publication time or update time, which can convey the immediacy and validity of the content to the reader, especially for content with strong timeliness.archiveDetailTags providedCreatedTime(creation time) andUpdatedTimeThe (update time) field. These two fields output timestamps, and we need to use tags to format them into the date and time format we want.stampToDatetags to format them into the date and time format we want.

stampToDateThe second parameter of the tag is a date format string that follows the Go language's date formatting rules, for example:"2006-01-02 15:04:05".

  • Display the document publication date:

    <span class="doc-publish-date">发布时间:{{ stampToDate(archive.CreatedTime, "2006年01月02日") }}</span>
    
  • Display the document publication date and time:

    <span class="doc-publish-datetime">发布于:{{ stampToDate(archive.CreatedTime, "2006-01-02 15:04:05") }}</span>
    
  • Display the document's most recent update time:

    <span class="doc-update-time">最后更新:{{ stampToDate(archive.UpdatedTime, "2006/01/02 15:04") }}</span>
    

    Here we assumearchiveThe variable is already available in the context of the current detail page, usually it is like this in the document detail page.

An application of integration: Build a complete document detail page header

Combining these elements, we can build a visually appealing and informative document detail page header. Below is a code snippet that demonstrates how to integrate images, views, and publishing time, while also supplementing the document title and category for a more comprehensive context:

<article class="doc-detail-wrapper">
    <h1 class="doc-title">{% archiveDetail with name='Title' %}</h1>

    <div class="doc-meta-info">
        <span class="doc-category">分类:
            <a href="{% categoryDetail with name='Link' %}">{% categoryDetail with name='Title' %}</a>
        </span>
        <span class="doc-publish-date">发布时间:{{ stampToDate(archive.CreatedTime, "2006年01月02日 15:04") }}</span>
        <span class="doc-views">阅读量:{% archiveDetail with name='Views' %} 次</span>
    </div>

    {% archiveDetail mainImage with name='Logo' %}
    {% if mainImage %}
    <div class="doc-featured-image">
        <img src="{{ mainImage }}" alt="{% archiveDetail with name='Title' %} 的配图" loading="lazy" />
    </div>
    {% endif %}

    <div class="doc-content">
        {# 这里会输出文档的正文内容,记得加上 |safe 过滤器以解析HTML #}
        {% archiveDetail fullContent with name='Content' %}
        {{ fullContent|safe }}
    </div>
</article>

By combining these flexible tags, we can easily create document detail pages that meet various design and functional requirements.The template tag design of AnQiCMS fully considers the actual needs of content operation, making technical implementation intuitive and efficient.


Frequently Asked Questions (FAQ)

  1. Ask: Why are the images, view counts, and publication time still not displayed after I follow the example code? Answer:First, please confirm that you have uploaded images when publishing documents in the background "Content Management".

Related articles

How to accurately retrieve and display the content of a specified ID or URL alias on the document detail page?

AnQiCMS (AnQiCMS) is an efficient and flexible content management system that provides users with a rich set of tools to build and manage websites.During website operations, we often need to precisely display the detailed content of a document on a specific page, whether it is the document being viewed on the current page or specified by a particular identifier (such as ID or URL alias).The template tag system of Anqi CMS, especially the `archiveDetail` tag, is the key to meeting this requirement.

2025-11-07

How to display thumbnails, descriptions, and custom fields on the document list page?

In website operation, the content list page is a key link for users to obtain information and decide whether to delve deeper into browsing.A richly informative, well-structured list page that can greatly enhance user experience and content appeal.It is particularly important to display thumbnails, descriptions, and custom fields reasonably in the document list page of Anqi CMS to achieve this goal.Through the powerful and flexible template tag system provided by Anqi CMS, you can easily meet this requirement without complex programming knowledge, just need to make simple modifications and configurations to the template file.

2025-11-07

How to manage and display all documents in AnqiCMS and support filtering by title, model, and category?

In the era of explosive digital content, efficiently managing and displaying website documents is a core challenge for every operator.When you have a vast amount of articles, product descriptions, service instructions, or any form of site content, how to ensure that these contents are organized, easy to find, and can be filtered according to different needs, is directly related to user experience and operational efficiency.AnqiCMS, as a system specially designed for enterprise content management, provides a powerful and flexible solution in this aspect.

2025-11-07

How to dynamically display the list of articles or products under a category in the navigation dropdown menu?

AnQi CMS: Build dynamic dropdown navigation menus to make content easily accessible In website operation, the navigation menu is the starting point for users to explore website content, and it is also an important clue for search engines to understand the website structure.The traditional navigation menu is often fixed links, when the website content becomes increasingly rich, especially when there are many articles and product types, manually maintaining the content list in the dropdown menu becomes particularly繁琐 and prone to errors.The AnQi CMS provides us with an elegant and efficient solution with its powerful content management capabilities

2025-11-07

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

The content is the soul of the website, and how to present these contents efficiently and beautifully is a topic of concern for every operator.In AnQi CMS, using Markdown to write content not only greatly improves writing efficiency, but also easily achieves complex layout requirements, such as inserting mathematical formulas and drawing flowcharts. This is undoubtedly a powerful feature for technical blogs, educational websites, or corporate websites that need to display complex business processes.Next, we will explore how to correctly render Markdown content as HTML in the Anqi CMS template

2025-11-07

How to use the `archiveList` tag to display a document list according to specified conditions (such as latest, most popular, recommended attributes)?

AnQiCMS is an efficient and flexible content management system that provides a variety of content display methods, among which the presentation of the document list is a very core part of website operation.We hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents on the homepage, category pages, or thematic aggregation pages according to different operational objectives.All of this can be easily achieved through the powerful `archiveList` tag of AnQiCMS

2025-11-07

How to implement a paginated document list display in `archiveList`?

When managing website content, we often encounter such situations: there are many articles, products, or news under a certain category. If all the content is piled on a single page, it not only causes the page to load slowly and affects user experience, but also makes it difficult for visitors to find what they need in a sea of information.At this point, introducing pagination becomes particularly important. Pagination can break a large amount of content into several small pages, allowing users to browse page by page, greatly enhancing the usability and access efficiency of the website.In AnQiCMS, implementing a document list display with pagination is very intuitive and flexible

2025-11-07

How to display the previous article and

In website content operation, the user experience of the document detail page is crucial.A well-designed page not only effectively displays content but also guides visitors to delve deeper into more related information.Among them, providing the "Previous" and "Next" navigation functions for users is a commonly used and efficient strategy to improve the internal link structure of the website, reduce the bounce rate, and optimize the user's browsing path.This not only helps users conveniently explore more content, but also conveys the relevance and depth of the website's content to search engines, which has a positive impact on SEO.

2025-11-07