How to use the `archiveList` tag to display the thumbnail of each article on the list page?

Calendar 👁️ 66

In AnQi CMS, to make your website's content list page more attractive, it is crucial to display a prominent thumbnail for each article or product to enhance user experience and the aesthetic beauty of the page.This not only helps visitors quickly understand the content topic, but also effectively improves click-through rate.AnQiCMS provides an intuitive and powerful template tag feature, allowing you to easily achieve this goal on the list page.

The core feature revelation:archiveListTags and thumbnails

In AnQiCMS, to achieve this goal, we mainly rely on the powerfularchiveList.archiveListTags are the core tools for retrieving and displaying lists of various types of content such as articles, products, and more. Whether you need to display the latest articles, popular products, or content under a specific category, archiveListcan be flexibly handled.

InarchiveListIn the loop, the data of each article is assigned to a variable (usuallyitem), which contains a field namedThumb, which is the address of the article thumbnail.item.ThumbThe thumbnail URL of the article processed by the system will be output directly.

Step-by-step operation: Display thumbnails on the list page.

We will guide you through specific steps on how to usearchiveListtags to display the thumbnail of each article.

Step 1: Determine your list page template file

First, you need to find the template file responsible for rendering the content list. According to the template convention of AnQiCMS, the list page template is usually located/templateUnder the folder of the template theme you are using, and follow the specific naming rules, for example:

  • Article list page: archive/list.htmlOr for specific categories:archive/list-{分类ID}.html
  • Product list page: product/list.htmlorproduct/list-{分类ID}.html
  • Or your custom model's list page.

Confirm the template file you want to modify, and use the "Template Design" feature in the background or edit it through FTP/SSH tools.

Step two: callarchiveListTags retrieve article data

In the list page template file, you will usearchiveListLabel to retrieve the list of article data. This label can be used according to your needs to filter and sort content through different parameters. For example, to get a model (such as the article model, itsmoduleIdThe pagination list under usually 1):“

{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {# 在这里循环处理每篇文章数据 #}
{% endarchiveList %}

In the above code:

  • archivesIs a variable name used to store the article list data retrieved. You can customize this variable name.
  • moduleId="1"It indicates getting the content of the article model under ID 1 (the article model is usually set to 1 by default, the product model is set to 2 by default, you can check the specific content model in the background).
  • type="page"Enable pagination functionality so that you can cooperatepaginationThe label displays the page number.
  • limit="10"Sets 10 articles per page.

Step 3: Extract and display thumbnails

After obtaining the list of article data, we can display it inarchiveListthe loop of the label (i.e.{% for item in archives %}and{% endfor %}Extract the thumbnail address of each article. Use{{item.Thumb}}to obtain the thumbnail URL and place it in<img>label'ssrcthe attribute.

We strongly recommend you for better user experience and SEO:

  • Add conditional judgment:Use{% if item.Thumb %}Check if the article has a thumbnail. If not, display a default placeholder to avoid blank or broken icons on the page.
  • Improvealtattribute:In<img>the tag withaltthe property, and using{{item.Title}}As its value, this is not only friendly to search engines, but also provides text descriptions when the image fails to load.
  • Add CSS class:With<img>Add a CSS class to the tag (for example,article-thumbnail),convenient for you to style thumbnails with CSS.

Complete code example

Integrate the above steps, a typical list page thumbnail display code may be as follows:

"twig {# 假设您正在编辑的是文章列表页模板,例如archive/list.html` #

{% archiveList archives with moduleId="1" type="page" limit="10" %}
    {% for item in archives %}
    <div class="article-item">
        <a href="{{item.Link}}" class="article-link">
            {% if item.Thumb %}
            <img src="{{item.Thumb}}" alt="{{item.Title}}" class="article-thumbnail">
            {% else %}
            {# 如果文章没有缩略图,可以显示一个默认占位图,请确保路径正确 #}
            <img src="/public/static/images/default-thumbnail.jpg" alt="默认缩略图" class="article-thumbnail">
            {% endif %}
            <h3 class="article-title">{{item.Title}}</h3>
            <p

Related articles

What is the difference in fetching images between the `Logo` and `Thumb` fields in the `archiveDetail` tag?

When managing content in Anqi CMS, we often encounter various fields related to images, among which the `Logo` and `Thumb` fields under the `archiveDetail` tag often confuse new users.They all represent images, but there are very clear and practical differences in terms of usage and system processing.Understanding these differences can help us better plan the content of images, improve the loading speed of the website, and enhance the user experience.### `Logo` field

2025-11-08

How to enable the automatic compression of large images in AnQiCMS and specify the compression width?

In website operation, images are the key elements that attract users and enrich content.However, large-sized images, while bringing visual impact, may also become a bottleneck for website loading speed, affecting user experience and even search engine rankings.AnQi CMS knows this pain point, built-in efficient image processing features, including the highly praised "auto-compress large image".This feature is designed to help you significantly optimize website performance and storage space without sacrificing too much image quality. To enable and configure this utility feature, you just need to log in to the Anqi CMS backend management interface.Log in to the background after

2025-11-08

Does AnQiCMS support automatic conversion of images to WebP format to optimize thumbnail performance?

In website operation, image loading speed is one of the key factors affecting user experience and search engine ranking.The WebP format, as a modern image format, is gaining popularity among websites due to its excellent compression performance that significantly reduces file size while maintaining visual quality.So, does AnQiCMS support automatic conversion of images to WebP format to optimize thumbnail performance?The answer is affirmative. AnQiCMS fully considers the website's needs for image optimization and loading speed, and built-in WebP image format conversion function. When you are

2025-11-08

How to batch regenerate thumbnails after changing the thumbnail settings?

When using AnQi CMS to manage website content, we sometimes encounter situations where we need to adjust the thumbnail display effect.This could be because the website has undergone a visual redesign, changed to a new template, or simply hopes to optimize the display of images on different devices.After changing the thumbnail size, cropping method, and other settings, the existing content on the website will not automatically apply these new settings. At this point, you need to manually trigger a batch regeneration to ensure the consistency and aesthetics of the thumbnails across the entire site.###

2025-11-08

How to get the thumbnail and background Banner image of the `categoryDetail` tag?

In AnQi CMS, the visual presentation of a website is the key to attracting visitors and conveying the brand image.Category thumbnails and background banners play a significant role in web page design, as they can directly display category content and enhance the aesthetics and user experience of the page.Anqi CMS provides flexible and easy-to-use template tags `categoryDetail`, which helps us easily obtain and display these visual elements.### Understanding the `categoryDetail` tag `categoryDetail`

2025-11-08

How to get the thumbnail or the first image of the slideshow group in the `pageDetail` tag?

In website operation, well-designed single-page (such as "About Us", "Service Introduction", etc.) is the key to showcasing brand image and conveying core information.These pages often need rich visual elements to attract visitors, and the effective use of images is an indispensable part of it.For users of AnQiCMS, the ability to flexibly obtain and display the first image from a thumbnail or slideshow is an important capability to achieve this goal.AnQi CMS provides a powerful template tag system

2025-11-08

The `thumb` filter can be used to process the image URL obtained from `categoryDetail` or `pageDetail`?

When using the AnQiCMS template, we often encounter the need to handle image links, especially for the display of thumbnails.The system provides multiple ways to obtain images, one common issue is about the combination of the `thumb` filter with the image fields in the `categoryDetail` or `pageDetail` tags.First, let's understand the basic logic of AnQiCMS in image processing.

2025-11-08

In AnQiCMS image resource management, how to replace an image while keeping the original URL unchanged?

In website content operation, images are indispensable visual elements that can effectively enhance the attractiveness and reading experience of the content.However, as the operation deepens, we often need to update the images to reflect the latest products, services, or design styles.

2025-11-08