How to use the `archiveList` tag to get the document list in AnQiCMS template?

Calendar 👁️ 90

As an experienced website operations expert, I deeply understand that how to efficiently obtain and display content is the core of building a website. Today, let's delve into a very important and powerful tag in the Anqi CMS template -archiveListIt can help us flexibly obtain various document lists, providing infinite possibilities for the presentation of website content.

Overview of core features: archiveListthe function

In AnQi CMS,archiveListTags are the foundation of content display. It is not just a simple document list retrieval tool, but also a multifunctional 'content scheduler'.With it, we can easily filter, sort, and display various types of documents, whether it's a regular article list, product display under a specific category, recommended articles related to the current content, or even a large amount of content that requires pagination.archiveListAll of them can handle it with ease.

Imagine, your website has a 'Latest News' section that needs to display the latest ten articles; or on the product detail page, you need to recommend several 'related products'; or on a category page, you need to present all articles in that category in a paginated form. The acquisition and display of these dynamic contents cannot be separated fromarchiveListThe exquisite application.

Basic syntax and beginner: how to callarchiveList

archiveListThe use of tags conforms to the unified style of Anqi CMS template engine, namely with{% %}wrapped, and throughwithPass parameters with keywords. Its basic structure is concise and clear:

{% archiveList 变量名称 with 参数 %}
    {% for item in 变量名称 %}
        {# 在这里展示文档内容 #}
    {% empty %}
        {# 如果没有内容,显示此段落 #}
    {% endfor %}
{% endarchiveList %}

Here, 变量名称is a variable you define yourself, for examplearchivesorarticles.archiveListThe tag will store the list of documents obtained in this variable, and then you can go on to do things likeforLoop through this variable, displaying the details of each document one by one.{% empty %}A clause is a very considerate design, which can elegantly display a prompt message when the list is empty, rather than making the page look empty.

Deep understanding:archiveListCommon parameters

archiveListThe power of tags lies in their rich parameter options. By combining these parameters, you can precisely control the scope and presentation of the documents you want to obtain.Let's take a look at several core parameters:

  1. Locate the content range:moduleIdwithcategoryId

    • moduleIdSpecify the document of the content model you want to retrieve. For example,moduleId="1"may represent the article model, andmoduleId="2"may represent a product model. This allows you to easily switch between different types of content.
    • categoryIdIf you only want to retrieve documents under a specific category, you can use this parameter. For example,categoryId="5"Will retrieve all documents under the category with ID 5. If you need to retrieve documents from multiple categories, you can separate them with a comma, such ascategoryId="1,2,3". It is worth mentioning that if set tocategoryId="0"Or completely omit this parameter,archiveListIt will try to retrieve the documents of the current page category or all categories, depending on the cooperation of other parameters.
    • excludeCategoryId: withcategoryIdOn the contrary, it is used to exclude documents of specified categories.
    • parentIdUsed to retrieve child documents under a parent document, which is very useful when building content with hierarchical relationships such as project cases and multi-step tutorials.
  2. Filter content attributes:flagwithexcludeFlagThe AnQi CMS supports setting various recommended attributes for documents (such as headlines [h], recommendations [c], slides [f], etc.).

    • flag: Passflag="c"You can only retrieve documents marked as 'recommended'.
    • excludeFlag: Used to exclude documents with specific properties, for exampleexcludeFlag="h"The headline article will not be displayed.
    • showFlag: If you need the flag attribute of the document to be displayed in the list, set it toshowFlag=true.
  3. Sorting and limiting:orderwithlimit

    • order: Determines the sorting method of the documents. Common values include:id desc(Sorted by ID in descending order, usually the most recent posts),views desc(Sorted by views in descending order, popular articles),sort desc(Sorted by custom backend). You can choose the most suitable sorting method according to your needs.
    • limit: Controls the number of documents returned.limit="10"It will only retrieve 10 documents. It also supportsoffsetpattern, such aslimit="2,10"Indicates starting from the second item to fetch 10 items, which is very suitable for skipping the first few items to display.
  4. Display mode:type typeThe parameter isarchiveListOne of the core features, which defines the display type of the document list:

    • type="list": Default mode, retrieves a specified number of documents without pagination. Suitable for sidebars, recommendation lists, etc.
    • type="page": Pagination mode. When you need to display a large number of documents in multiple pages, you must use this type. It will cooperatepaginationCreate pagination links with tags.
    • type="related": Related document mode. Typically used on detail pages, intelligently recommending related content based on the current document category, keywords, or backend settings.
  5. Dynamic search and filtering:qWith custom filtering parameters

    • qUsed to implement search functionality. For example,q="关键词"Only documents with the keyword in the title will be displayed. Whentype="page"then,archiveListIt will automatically read the parameters in the URL.qfor searching.
    • Custom filter parameters: If you define filterable fields in the background content model (such as "gender", "region"), these fields can be passed to the URL parameters viaarchiveListPerform advanced filtering, for examplesex=男.
  6. Multiple sites and combined documents:siteId/combineIdwithcombineFromId

    • siteId: If you have enabled the multiple sites feature, you cansiteIdspecify from which site to retrieve documents.
    • combineId/combineFromIdThis is a unique and powerful feature of AnQi CMS, used to implement the 'combination comparison' of documents.For example, on a travel route website, you can combine the travel information of "Beijing" and "Shanghai" into a "travel route from Beijing to Shanghai", and then obtain the data of these two documents in the template for comparison and display.

Data access:archiveListFields available in the loop

OncearchiveListFill data into your custom variables (for examplearchives) so you can access various properties of each document. Common fields include:forthrough the loopitemVariable access to various properties of each document. Common fields include:

  • item.Id: Document ID.
  • item.Title: The document title.
  • item.Link: Document link.
  • item.Description: Document description.
  • item.Logo: The cover image of the document (usually the large image of the thumbnail).
  • item.Thumb: The thumbnail of the document cover.
  • item.Views: Document views.
  • item.CreatedTime: The creation time of the document (timestamp, which needs to be配合stampToDateFiltered formatting()).
  • item.UpdatedTimeThe document update time (timestamp, formatted as well).
  • item.CategoryIdThe document category ID it belongs to.
  • And all custom fields in the content model, you can directly access throughitem.自定义字段名.

Time formatting prompt: Due toCreatedTimeandUpdatedTimeIt is a timestamp, you need to usestampToDateThe filter to convert it to a readable date format, such as{{stampToDate(item.CreatedTime, "2006-01-02 15:04")}}.

Practical Scenarios and Examples

To help you understand betterarchiveListActual application, we

Related articles

What are the functions of the 38 commonly used tags in AnQiCMS templates?

As an experienced website operations expert, I have a deep understanding of the powerful functions of AnQiCMS (AnQiCMS) and its flexible template system.It is not just a content management system, but also a tool that empowers enterprises and content operation teams, especially in terms of content display and management. Its core lies in a set of elegantly designed and feature-rich template tags system.Today, let's delve deeply into the 38 commonly used tags in the Anqi CMS template, see what roles they play, and how they help us easily build and manage all kinds of websites.

2025-11-07

What are the naming conventions for the document detail page and list page template files in AnQiCMS?

As a senior website operation expert, I am well aware that the naming rules of a content management system template are not only technical details, but also the foundation of content operation efficiency and website maintainability.AnQiCMS (AnQiCMS) is designed with flexibility and efficiency, and also provides clear and practical naming conventions in template management, allowing developers and operators to operate with ease.Today, let's delve into the naming rules of AnQiCMS's document detail page and list page template filenames to help you better master this powerful tool.

2025-11-07

How to include header, footer, and other common code snippets in AnQiCMS templates?

## AnQiCMS template development: clever integration of common code snippets, making your website maintenance more efficient When operating a website, we often find that many pages share the same basic structure, such as the website header, footer, sidebar navigation, or a general ad slot.If you have to rewrite this code for each page repeatedly, it is not only inefficient but also, once you need to make changes, you have to adjust them one by one, which is undoubtedly a nightmare for website maintenance.It is good that AnQiCMS is an enterprise-level content management system developed in Go language

2025-11-07

What template types does AnQiCMS support (adaptive, code adaptation, PC + mobile)?

## AnQiCMS Template World: Flexible for various screens, making your website omnipresent In the wave of digitalization today, whether your website can seamlessly present on various devices is directly related to user experience and brand image.As an experienced website operations expert, I am well aware of the importance of a flexible and efficient content management system (CMS) to a company.

2025-11-07

How to use the `archiveDetail` tag to get detailed information of a specific document?

As an experienced website operation expert, I know that content is the soul of the website, and how to efficiently and accurately present these contents is an indispensable part of our daily work.In such a powerful content management system as AnQiCMS, making good use of the template tags provided can greatly enhance our content operation efficiency.

2025-11-07

How to implement navigation between previous and next document sections using the `prevArchive` and `nextArchive` tags?

## Easily Navigate: How to Use `prevArchive` and `nextArchive` Tags for Smart Article Navigation in AnQiCMS As an experienced website operator, we know that website content is not just about publishing. How to allow users to smoothly browse through massive amounts of information and find the next article they are interested in is crucial for improving user experience, extending stay time, and even optimizing SEO. In the powerful and flexible content management system AnQiCMS (AnQiCMS)

2025-11-07

How to get the specified model or sub-categories under the parent category of the `categoryList` tag?

## Taming AnQiCMS `categoryList` tag: How to efficiently obtain the specified model and subcategories under the parent category In the daily operation of AnQiCMS, content classification is the core of the website structure, which not only relates to the smoothness of the user's browsing experience but is also a key element that cannot be ignored in search engine optimization (SEO). In order to help everyone better manage and display website content, today we will delve into a very practical and powerful template tag in AnQiCMS——`categoryList`

2025-11-07

How to call the document's Tag list with `tagList` tag?

## The Powerful Assistant for Content Operation: The Clever Use of `tagList` Tag in AnQiCMS In the vast sea of the Internet, how to efficiently organize information, make it easy to find, and ultimately reach the target users accurately is a problem that every content operator is thinking about. AnQiCMS (AnQiCMS), as a content management system designed for enterprises and self-media, understands this pain point and provides powerful tools such as `tagList` in its powerful template tag system, helping us easily master content tags and add the charm of classification and aggregation to the website.

2025-11-07