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

Calendar 👁️ 63

AnQiCMS as an efficient and flexible content management system provides a variety of content display methods, among which the presentation of the document list is a very core part of website operation.Whether it is the homepage of the website, the category page, or the topic aggregation page, we hope to dynamically display the latest articles, the most popular content, or carefully recommended high-quality documents according to different operational goals.All this can be done through the powerful AnQiCMSarchiveListLabel it easily.

archiveListThe tag is the core tool we use in the AnQiCMS template to retrieve and display document lists.It allows us to precisely control which documents to display, how to sort them, and how many to show.Let's explore how to cleverly use this tag to create a document list that meets various needs.

Flexible call: Basic document list display

While usingarchiveListWhen labeling, it is usually structured in such a way:

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
    <li>
        <a href="{{item.Link}}">{{item.Title}}</a>
        {# 更多文档字段如 item.Description, item.CreatedTime, item.Views 等可以在这里展示 #}
    </li>
    {% empty %}
    <li>暂时没有找到相关内容。</li>
    {% endfor %}
{% endarchiveList %}

here,archivesIt is a custom variable name used to store the list of documents obtained.type="list"It means we want to get a simple list, andlimit="10"It limited to display only the latest 10 documents. When the list is empty,{% empty %}the content in the block will be displayed as a friendly reminder to the user.

Display the latest documents: Keep information always fresh

Users always crave for the latest information. Displaying the latest articles on blogs, news, or industry information sites is an important strategy to attract users and maintain activity. WitharchiveListWe just need to adjustorderthe parameters, we can easily implement the 'Latest Documents' list.

To sort by publication time in descending order, that is, the latest documents are listed first, we can setorder="id desc". Here,idIt usually represents the unique identifier of a document, and the higher the value, the later the document was published.

{# 显示最新的5篇文章 #}
{% archiveList latestArticles with order="id desc" limit="5" %}
    {% for item in latestArticles %}
    <div class="article-card">
        <h4><a href="{{item.Link}}">{{item.Title}}</a></h4>
        <p>发布时间:{{stampToDate(item.CreatedTime, "2006-01-02")}}</p>
    </div>
    {% endfor %}
{% endarchiveList %}

By this code, the website will dynamically pull the latest five articles released in the system, and sort them in chronological order to ensure that visitors see the latest content first.

Display the hottest documents: Insight into user interest focus

The "hot document" often represents the content that the current user is most interested in and the most frequently discussed.It can help new users quickly understand the popular trends of the website and also inspire the enthusiasm of old users.In AnQiCMS, the document's 'views' are an important indicator of its popularity.Therefore, we can go throughorder="views desc"Come and get the hottest documents.

{# 显示浏览量最高的8篇文档 #}
{% archiveList hottestArticles with order="views desc" limit="8" %}
    {% for item in hottestArticles %}
    <div class="popular-item">
        <a href="{{item.Link}}">{{item.Title}}</a>
        <span>({{item.Views}}次阅读)</span>
    </div>
    {% endfor %}
{% endarchiveList %}

This way, your website can intelligently display the articles with the highest views and popularity, allowing users to see at a glance what everyone is paying attention to.

Recommended: Use recommendation attributes to promote accurately

In addition to the latest and the most popular, we often need to manually tag some "excellent recommendations", "headlines", "slides", and other documents according to operational strategies to highlight their importance.AnQiCMS provides a flexible "recommended attribute" feature in the background, allowing us to set different tags for documents (such as "headline[h]", "recommended[c]", "slide[f]", "special recommendation[a]", "scroll[s]", "image[p]", "jump[j]", etc.).

InarchiveListIn tags, we can pass throughflagParameters to specify the recommendation attributes to be filtered. Please note,archiveListTags can only filter one at a time in a single callflagProperty.

For example, if you want to display the document marked as "slide[f]" on the homepage, you can set it up like this:

{# 显示标记为“幻灯”的3篇文档作为轮播图 #}
{% archiveList slideDocs with flag="f" limit="3" %}
    {% for item in slideDocs %}
    <div class="swiper-slide">
        <img src="{{item.Logo}}" alt="{{item.Title}}">
        <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
    </div>
    {% endfor %}
{% endarchiveList %}

If you want to display the document marked as "recommended[c]" in the sidebar:

{# 显示标记为“推荐”的6篇文档 #}
{% archiveList recommendedArticles with flag="c" limit="6" %}
    <ul class="sidebar-recommend">
    {% for item in recommendedArticles %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
    </ul>
{% endarchiveList %}

In this way, you can display different types of selected content in different areas of the website based on specific attributes set for the document in the background, greatly enhancing the flexibility of content operations.

Advanced Applications and Precautions

archiveListThe power of tags goes beyond this, as they also support more parameter combinations to meet more complex display needs:

  • Specify the category: Use.categoryIdThe parameter can limit the document to come only from a specific category. For example,categoryId="1"Only the ID of

Related articles

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 `archiveDetail` tag to display images, view counts, and publishing time on the document detail page?

In website operation, the document detail page is the core area that attracts users and conveys information.A rich content, intuitive detail page, which can not only significantly improve user experience, but also has a positive push on search engine optimization (SEO).AnQiCMS provides a powerful `archiveDetail` tag that allows us to easily obtain and display various document information, such as images, view counts, and publication time.Next, we will explore how to skillfully use the `archiveDetail` tag in the document detail page

2025-11-07

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 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

How does AnQiCMS display the latest article list on the homepage?

The homepage is the first impression of visitors arriving at the website, and the timely update of the latest article list can effectively enhance the activity and user stickiness of the website.For users using AnQiCMS, displaying the latest list of published articles on the homepage is a basic and important feature, which can be easily achieved through the flexible template tags provided by the system.AnQiCMS with its efficient and customizable features provides users with an intuitive template system.You do not need to delve deeply into the complex backend code, just master its powerful template tag usage

2025-11-07

How to display a document list on the AnQiCMS website based on a specific category ID?

In AnQiCMS, displaying a document list based on a specific category ID is a very basic and commonly used feature, which allows us to flexibly organize and present website content.AnQiCMS's powerful template tag system makes this operation intuitive and efficient.No matter where you want to manually insert a category of documents on a page, or want the entire category page to automatically display the documents under it, the system provides the corresponding solutions.

2025-11-07