How to get the thumbnail, description, and publish time of the document in the `archiveList` loop?

Calendar 👁️ 53

As an experienced website operations expert, I know that how to efficiently and flexibly display content in a content management system is one of the key factors for the success of a website.AnQiCMS (AnQi CMS) relies on its powerful template engine and concise tag design, making content display extremely convenient.archiveListIn the loop, elegantly obtain and display the document thumbnail, description, and publication time.

Start content loop:archiveListThe magic of tags

In AnQiCMS,archiveListThe tag is a core tool used to retrieve and display document lists in a loop.No matter whether it is the content of an article, product, or other custom model, it can help us easily iterate through processing.archiveListIt is the starting point to achieve this goal.

It is usually presented in such a structure in your template file:

{% archiveList archives with type="list" limit="5" %}
    {% for item in archives %}
        {# 在这里处理每一个文档项,item代表当前循环中的文档对象 #}
    {% endfor %}
{% empty %}
    {# 如果没有文档,这里的内容会被显示 #}
{% endarchiveList %}

In this code block,archivesIs a variable name we give to the document list,itemIt represents the object of the current document in each loop. All the data we need will be extracted from thisitemobject.

Presented in detail: Get the thumbnail of the document

The visual appeal of website content is self-evident, and thumbnails are the key to enhancing this appeal. In AnQiCMS, obtaining document thumbnails is very intuitive, mainly throughitem.Thumboritem.Logoto implement the field.

  • item.ThumbThis field usually points to the thumbnail path that has been optimized by the system.AnQiCMS when you upload document images, it will automatically generate thumbnails of different sizes according to the backend settings.If you do not manually upload a thumbnail when publishing a document, but the document content contains images, the system will also intelligently extract the first image as a thumbnail.item.Thumbis the recommended thumbnail field for list pages, as it is usually smaller in size and faster to load.

  • item.Logo: Compared to,item.LogoThe field may point to the main cover image of the document, which is usually in its original size or a larger size.In certain design scenarios, if you need to display a higher resolution or more complete cover, you can use this field.

The following is an example of the code used in the template:

{% if item.Thumb %}
    <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="document-thumbnail">
{% else if item.Logo %}
    <img src="{{ item.Logo }}" alt="{{ item.Title }}" class="document-logo">
{% endif %}

By making such a condition judgment, we can ensure that even if the document does not haveThumbimage, we can also try to useLogoimage as an alternative, or avoid displaying broken image icons when both are missing.

Concise summary: Get the document description

The document description, also known as an abstract, is the important text that guides users to click and read. It needs to briefly summarize the core content of the document. AnQiCMS stores the document description initem.Descriptionin the field.

This field's content can be directly output:

<p class="document-description">{{ item.Description | truncatechars:120 }}</p>

I added one heretruncatechars:120Filter, this is a very practical feature of AnQiCMS template engine, which can truncate the description text to a specified number of characters (here are 120 characters) and automatically add an ellipsis at the end.This is very helpful to maintain the neat and unified layout of the list page.It is worth mentioning that if you do not manually fill in the description when publishing the document, AnQiCMS will automatically extract the first 150 characters of the document content as the description, which greatly reduces the burden on content operators.

Trace time: Get the publication time of the document

The publication time is an important indicator for users to judge the timeliness and value of the content. In AnQiCMS, the publication time of the document is stored initem.CreatedTimethe field. But it should be noted that,CreatedTimeThe field returns a Unix timestamp (10 digits), and we need to format it into a common date-time format for user convenience.

AnQiCMS provides a namedstampToDateThe built-in label, specifically used for formatting timestamps. Its usage is{{ stampToDate(时间戳, "格式") }}. The "format" parameter follows the Go language's time formatting rules, for example"2006-01-02"stands for year, month, and day,"15:04:05"represents hours, minutes, and seconds.

Here are some common examples of time formatting:

{# 格式化为:2023年01月01日 #}
<span>发布于:{{ stampToDate(item.CreatedTime, "2006年01月02日") }}</span>

{# 格式化为:2023-01-01 12:30 #}
<span>发布于:{{ stampToDate(item.CreatedTime, "2006-01-02 15:04") }}</span>

{# 格式化为:Jan 01, 2023 #}
<span>发布于:{{ stampToDate(item.CreatedTime, "Jan 02, 2006") }}</span>

exceptCreatedTime(Creation time), you can also useitem.UpdatedTimeto get the update time of the document, which also requiresstampToDateto format.

A comprehensive integration of: A completearchiveListLoop example

Now, let's integrate these elements into a completearchiveListLoop to simulate the display of a content list:

<div class="document-list-section">
    {% archiveList archives with type="list" limit="6" order="id desc" %} {# 获取最新发布的6篇文档 #}
        {% for item in archives %}
            <div class="document-card">
                {% if item.Thumb %}
                    <a href="{{ item.Link }}" class="document-image-link">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}" class="document-cover-image">
                    </a>
                {% endif %}
                <div class="document-info">
                    <h3 class="document-title"><a href="{{ item.Link }}">{{ item.Title }}</a></h3>
                    <p class="document-excerpt">{{ item.Description | truncatechars:100 }}</p>
                    <div class="document-meta">
                        <span class="document-date">发布于:{{ stampToDate(item.CreatedTime, "2006年01月02日") }}</span>
                        <span class="document-views">浏览:{{ item.Views }}</span>
                    </div>
                </div>
            </div>
        {% empty %}
            <p class="no-content-message">很抱歉,当前暂无文档可供显示。</p>
        {% endfor %}
    {% endarchiveList %}
</div>

In this example, we not only got the thumbnail, description, and publish time, but also displayed the document title and

Related articles

How to call the document data of different sites (`siteId`) through the `archiveList` tag?

As an experienced website operations expert, I fully understand the challenges you may encounter when managing multi-site content.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful multi-site management capabilities.Today, let's delve into how to use the `archiveList` tag and its core parameter `siteId` to easily implement cross-site document data calls.

2025-11-06

How to retrieve related content of the current document using the `archiveList` tag's `type="related"` mode?

As an experienced website operations expert, I am very happy to delve deeply into the `archiveList` tag in AnQiCMS with the `type="related"` mode, which plays a crucial role in content operations and can effectively improve user experience and the website's SEO performance. --- ## In-depth Analysis of AnQiCMS's `archiveList` Tag: How to intelligently retrieve related content and enhance user experience In such an efficient and customizable content management system as AnQiCMS

2025-11-06

How to use the `archiveList` tag to perform keyword search (using `q` parameter) to filter documents on the frontend page?

## Unlock AnQiCMS: Use the `archiveList` tag to implement keyword search and content filtering on the front-end page As an experienced website operations expert, I am well aware of the importance of an efficient and flexible content management system for enterprises.AnQiCMS, this system developed based on the Go language, with its excellent performance and rich features, is becoming the preferred choice for an increasing number of small and medium-sized enterprises and content operation teams.In today's era of information explosion, whether users can quickly find the content they need is directly related to the user experience and conversion rate of the website.

2025-11-06

How to set the display quantity and offset for the `archiveList` tag in AnQiCMS to achieve pagination?

As an experienced website operations expert, I know that an efficient and flexible list display method is crucial for user experience and website performance.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful template tag system.Today, let's delve into how to cleverly set the display quantity and offset using the AnQiCMS `archiveList` tag to achieve a smooth pagination effect.

2025-11-06

How to display the Flag attribute of the document in the `archiveList` loop, for example, 'Recommended' or 'Bold'?

As an experienced website operations expert, I am happy to deeply analyze how to flexibly use the `archiveList` loop in AnQiCMS to display the Flag attribute of documents, such as "recommended" or "bold".The core of content operation lies in how to effectively distinguish and highlight key content, and the Flag attribute is a powerful and easy-to-use feature provided by AnQiCMS for this purpose.--- ### Light up your content

2025-11-06

How to combine `archiveList` with `pagination` tag to implement pagination navigation for document list?

As an experienced website operation expert, I am well aware of the importance of an efficient content management system (CMS) for website operation. AnQiCMS, with its high concurrency features in Go language and flexible template mechanism, has provided us with great convenience.Among many features, how to effectively display a large number of documents and provide friendly pagination navigation is crucial for improving user experience and content accessibility.Today, let's delve into how the `archiveList` tag cleverly combines with the `pagination` tag

2025-11-06

How to get the SEO title, keywords, and description of the current document and use it in the page Meta tags?

As an expert well-versed in website operations, I know the importance of SEO titles, keywords, and descriptions (usually referred to as TDK, Title, Description, Keywords) for a website to perform well in search engines.They are the information that users see first on the search results page, directly affecting the click-through rate, and are also a key signal for search engines to understand the content of the page.

2025-11-06

How does the `archiveDetail` tag in AnQiCMS control the Markdown rendering or lazy loading of document content?

As an experienced website operations expert, I know that in the increasingly fierce online environment, efficient content management and elegant presentation are crucial for the success of a website.AnQiCMS is a powerful and flexible content management system that provides us with great convenience with its template tag system.Today, let's delve deeply into a seemingly simple yet powerful tool: the `archiveDetail` tag of AnQiCMS, especially its mysteries in controlling the Markdown rendering and lazy loading of document content.

2025-11-06