How to accurately control the display quantity, sorting, and filtering conditions of the `archiveList` tag?

Calendar 👁️ 79

In AnQi CMS,archiveListThe label is the core tool for dynamically calling and displaying document lists.Whether it is a blog article, product showcase, or news update, this tag can help you flexibly control the display quantity, sorting method, and various filtering conditions according to your specific needs.A deep understanding of its parameters will enable you to build highly customized and powerful content display pages.

Precisely control the number of documents displayed:limitParameter usage

The number of documents in the document list is controlled mainly throughlimitParameters are implemented. It determines how many document data will be displayed each time the call is made.

  • Basic quantity limit: If you want the page to display a fixed number of documents, such as the latest 5 articles published, you can directly setlimit="5".
    
    {% archiveList archives with limit="5" %}
        {# 遍历并显示文档 #}
    {% endarchiveList %}
    
  • Start position and quantity limit (offset mode): When you need to start fetching data from a specific position in a document list, you can use the offset mode. For example, to start from the 3rd document and fetch 10 documents, you can setlimit="2,10"(Please note that the index starts from 0, so 'starting from the third one' means an offset of 2).
  • Combined with pagination.:limitThe parameter withtype="page"Combined, it prepares for pagination functionality. In this mode,limitdefines the number of documents displayed per page, while the actual pagination navigation needs to be配合paginationtags to generate.
    
    {% archiveList archives with type="page" limit="10" %}
        {# 遍历并显示当前页的文档 #}
    {% endarchiveList %}
    {% pagination pages with show="5" %}
        {# 显示分页导航 #}
    {% endpagination %}
    

Flexibly set document sorting:orderThe magic of parameters

orderThe parameter allows you to specify the sorting rules of the document list to meet different content display logic.

  • Sort by ID:order="id desc"Documents are sorted in descending order by document ID, usually used to display the latest documents (the larger the ID, the newer it is). If you want to sort in ascending order, it will beorder="id asc".
  • Sorted by views:order="views desc"Documents are sorted in descending order by the number of views, commonly used to display popular or highly relevant documents.
  • Sorted by custom order in the background.: The AnQi CMS backend allows you to manually adjust the document sorting. At this time, useorder="sort desc"ororder="sort asc"You can display documents according to the custom order set in the backend. If you do not specifyorderParameters, by default, will also be sorted according to the custom sorting of the background (sort desc) performed.

For example, display the top 5 latest articles:

{% archiveList hotArticles with limit="5" order="views desc" %}
    {# 遍历并显示热门文档 #}
{% endarchiveList %}

Precisely filter the document list: multi-dimensional condition setting

archiveListTags provide rich filtering options, helping you accurately lock in the required documents.

  • Filter by content model (moduleId): Anqi CMS supports custom content models, such as "article model", "product model", etc. ThroughmoduleIdParameters, you can specify to only retrieve documents under a specific content model. For example,moduleId="1"Retrieve document model articles,moduleId="2"Retrieve product model documents.

    {% archiveList products with moduleId="2" limit="10" %}
        {# 显示产品列表 #}
    {% endarchiveList %}
    
  • Filter by category (categoryId,excludeCategoryId,child)This is one of the most commonly used filtering methods.

    • categoryId="1"Only show documents under the category with ID 1. You can pass multiple category IDs, such ascategoryId="1,2,3".
    • excludeCategoryId="4"Exclude documents from the category with ID 4. Also supports multiple IDs.
    • child="true"(Default value): When specifiedcategoryIdInclude documents from all subcategories as well.
    • child="false"When specifiedcategoryIdWhen, only the documents of the current category itself are displayed, without including the subcategories.
    • If you wisharchiveListDo not automatically read the category ID of the current page, you can explicitly set it.categoryId="0".
    {# 显示分类ID为1及其子分类下的最新10篇文章 #}
    {% archiveList articles with categoryId="1" child="true" order="id desc" limit="10" %}
        {# ... #}
    {% endarchiveList %}
    {# 只显示分类ID为5的文档,不含子分类 #}
    {% archiveList docs with categoryId="5" child="false" limit="5" %}
        {# ... #}
    {% endarchiveList %}
    
  • Filter by recommended attributes (flag,excludeFlag,showFlag)In the background, when editing documents, you can set recommended attributes such as 'Headline[h]', 'Recommended[c]', 'Slide[f]', and others.

    • flag="c"Only display documents with the 'recommended' attribute. Can be combined, such asflag="h,c".
    • excludeFlag="s"Exclude documents with the 'scroll' attribute.
    • showFlag="true": Display recommended document properties in the document list, making it convenient for you to display different properties in the template according to the properties.
    {# 显示所有带有“幻灯”属性的文档 #}
    {% archiveList slides with flag="f" limit="3" %}
        {# ... #}
    {% endarchiveList %}
    
  • Filter by search keywords (q): Whentype="page"mode, qThe parameter can be used to specify the search keyword. It is worth noting that if the query parameter is already included in the URLq=关键词.archiveListit will automatically read and apply this keyword to search.

    {# 在搜索结果页,显示标题包含“SEO”关键词的文档 #}
    {% archiveList searchResults with type="page" q="SEO" limit="10" %}
        {# ... #}
    {% endarchiveList %}
    
  • Filter by specific user (userId) If you need to display documents published by a specific author or user, you can useuserIdthe parameters. For example,userId="1"

Related articles

How to customize independent display templates for specific content on the AnQiCMS website (such as documents, categories, single pages)?

In website operation, we often encounter scenarios where we need to give specific content a unique appearance.It may be a "About Us" page carrying important information, needing a unique layout; it may also be a series of product details, hoping to show different parameter comparisons; or even a content category, looking forward to presenting the list in a more attractive way.

2025-11-08

How does AnQiCMS's adaptive, code adaptation, and PC+Mobile independent mode affect the display effect of the website on different devices?

In today's multi-screen interconnected era, whether a website can display smoothly and efficiently on different devices is directly related to user experience and brand image.AnQiCMS is a rich-featured enterprise-level content management system that fully understands this, providing users with three flexible website display modes to meet the diverse needs of device access: adaptive, code adaptation, and PC+Mobile independent mode.Understanding the working principles and their impact on the display effects of websites is crucial for operators.

2025-11-08

How to ensure UTF-8 encoding when creating AnQiCMS templates to avoid garbled front-end pages?

When using AnQiCMS to build a website, ensure that the front-end pages display normally and avoid annoying garbled characters, which is an important detail that every operator needs to pay attention to.Where, the character encoding of the template file is a key point.If the encoding setting of the template file is incorrect, even if the content of the website itself is not a problem, the page that ultimately appears to the user may be a bunch of unrecognizable characters.

2025-11-08

How to use the Go language features of AnQiCMS to implement the rapid loading and smooth display of website front-end content?

In today's rapidly changing digital age, the loading speed of websites and the smooth display of content have become key indicators of user experience and SEO performance.AnQiCMS (AnQiCMS) leverages its powerful genes based on the Go language to provide solid technical support for the rapid loading and smooth display of website front-end content.Go language is renowned for its exceptional performance and concurrent processing capabilities.As a compiled language, Go code is efficiently converted into machine code before execution, which means the program has extremely high execution efficiency.

2025-11-08

How to use the `archiveDetail` tag to retrieve and fully display the title, content, and custom fields of a specific document?

In AnQiCMS, displaying the detailed content of a single document is one of the core requirements for website construction.Whether it is an article detail page, a product detail page, or other custom type of content display, we need a flexible and efficient way to obtain and present the title, body of the document, and custom fields defined according to business requirements.The `archiveDetail` tag was born for this purpose, it can help you easily achieve this goal.### Deeply understand the `archiveDetail` tag

2025-11-08

How do the `prevArchive` and `nextArchive` tags display the link and title of the previous/next document on the document detail page?

When we browse content on the website built with AnQiCMS, carefully crafted documents bring value to readers.It is particularly important to provide 'Previous' and 'Next' navigation links at the end of each article to make the reader's reading experience more smooth and encourage them to explore more relevant content.This can effectively guide users to deeply browse within the website, increase page visits and user stickiness, and is also very beneficial for the internal link structure and SEO optimization of the website.

2025-11-08

How to use the `categoryList` tag to build a multi-level category navigation or display category lists in the content area?

In Anqi CMS, properly organizing website content categories is an important aspect for improving user experience and website maintainability.Whether it is to build a clear multi-level navigation menu, help users quickly locate information, or skillfully display different categories of content in the page content area, the `categoryList` tag is the core tool for realizing these functions. ### Core Tag: `categoryList` Description The `categoryList` tag is used specifically in the Anqi CMS template engine to retrieve the website category list.

2025-11-08

How to retrieve and display the name, description, Banner image, and thumbnail of a specific category using the `categoryDetail` tag?

In AnQiCMS template creation, we often need to retrieve and display detailed information about specific categories, such as the name, description, and even preset Banner images and thumbnails.`categoryDetail` tag is born for this, it helps us easily extract this data from the database and flexibly display it on the website front end.

2025-11-08