How to use the `archiveList` tag in AnQiCMS templates to flexibly display document lists?

Calendar 👁️ 74

In AnQi CMS, when we need to dynamically display articles, products, or other document lists on the website, archiveListTags are an indispensable core tool. They provide high flexibility and powerful functionality, whether you want to display the latest content, popular articles, products under specific categories, or even generate lists based on keyword search or customized filtering conditions.archiveListCan easily handle.

archiveListThe core function and basic usage

archiveListTags are mainly used to query and display document collections that meet specific conditions from the database. Its basic usage structure usually includes two parts:archiveListThe tag itself is used to define query conditions as well as aforLoop is used to traverse each document data found.

Here is an example of a typical usage:

{% archiveList archives with type="list" limit="10" %}
    {% for item in archives %}
        <li><a href="{{ item.Link }}">{{ item.Title }}</a></li>
    {% endfor %}
{% endarchiveList %}

In this example:

  • archiveListIs the tag name.
  • archivesIt is a custom variable name used to store the document list data retrieved. You can name it according to your preference.articles/productsetc.
  • with type="list" limit="10"It is used to specify the query parameters.type="list"Indicates that we want to get a simple list, not a paginated list or related document list;limit="10"limits the number of displayed documents to 10.
  • {% for item in archives %}statement is used to traversearchivesEach document data in the variable. Inside the loop,itemThe variable represents the document being processed.
  • {{ item.Link }}and{{ item.Title }}are used to output the current document's link and title.

Flexibly control the acquisition and display of documents

archiveListTags provide rich parameters, allowing us to accurately control which documents to retrieve and how to sort them.

  1. Content location: Specify where to obtain the document

    • moduleId: If your website has multiple content models (such as articles, products), you canmoduleId="1"(Assuming the article model ID is 1) to specify only to retrieve the article model documents.
    • categoryId: Do you want to display documents under a specific category? UsecategoryId="分类ID"If you need to display documents of multiple categories, you can separate multiple IDs with a comma, for examplecategoryId="1,2,3"It is worth noting that if you do not specifycategoryIdIt will try to automatically read the category ID of the current page, and if you want to disable this automatic behavior, you can explicitly set it tocategoryId="0".
    • excludeCategoryId: Sometimes we may need to exclude certain categories of documents, at which point we can useexcludeCategoryId="要排除的分类ID".
    • flag,excludeFlag: Anq CMS supports setting multiple recommended attributes for documents, such as头条[h]/推荐[c]/幻灯[f]etc. Passedflag="c"You can easily retrieve all documents marked as "recommended". Similarly,excludeFlagThe parameter can help you exclude documents with specific attributes.
    • child: By default,categoryIdIt will include the documents under its subcategory. If you only want to get the documents of the specified category itself and not include its subcategory, you can setchild=false.
    • userId,parentId: For documents published by a specific author or documents with parent-child relationships, these parameters also provide precise positioning functionality.
    • siteId: For scenarios of multi-site management, you can go throughsiteIdSpecify the parameter to get data from which site, to achieve cross-site content calling.
  2. Display order and quantity: how to sort and limit the number of items

    • order: The document sorting method is very critical. You can sortidDescending (id desc) to get the latest released documents, or sortviewsDescending (views desc) Show popular content. If you have set custom sorting in the background,order="sort desc"it will display according to your settings.
    • limit: This parameter controls the number of documents displayed in the list, for examplelimit="10"Display 10 items. It also supportsoffset,limitin the form of, for examplelimit="2,10"means starting from the second document and retrieving 10 items.
  3. List type:list/pagewithrelated

    • type="list": This is the simplest list mode, sorted bylimitThe specified parameter quantity is displayed directly in the document.
    • type="page": When you need to add pagination functionality to the document list, you should usetype="page". At this point, you also need to combine with the services provided by Anqi CMS.paginationTag to build pagination navigation, realizing functions such as "Previous page", "Next page", and page jump.
    • type="related"Used to retrieve related documents on the document detail page. It intelligently recommends content based on the current document's categories or other metadata. You can also access it bylike="keywords"Let it match related documents based on keywords orlike="relation"Only display related documents manually set up in the background.
  4. Advanced usage: Search with custom filtering

    • q: Whentype="page"then,qParameters can be used to implement search functionality. You canarchiveListspecify in the tag directlyq="搜索关键词"or, more flexibly, let it automatically read the URL in theqQuery parameters to achieve dynamic display of search results after the user enters keywords in the search box.
    • Filter parameters: If you define additional filterable fields in the background content model for documents (such as the 'type' and 'area' on real estate websites), these filter conditions can be passed to the URL query parameters.archiveListCombined.archiveFiltersLabel, you can build a powerful filtering navigation.
    • combineIdandcombineFromIdThis is a very unique and powerful set of parameters, suitable for scenarios where it is necessary to display two documents together, such as 'a travel route from City A to City B'.They allow you to dynamically append the content of another document to the current document in a list, and reflect this combination relationship in the link.

Document data available in the loop.

Infor item in archivesthe loop,itemThe object contains rich information about the current document, you can call it according to your needs:

  • Basic information:{{ item.Id }}(ID),{{ item.Title }}(Title),{{ item.Link }}(Link),{{ item.Description }}(Description),{{ item.Views }}(Views) etc.
  • Time information:{{ stampToDate(item.CreatedTime, "2006-01-02") }}(Publication time, required)stampToDateformatted).
  • Image information:{{ item.Logo }}(Cover main image),{{ item.Thumb }}(Cover thumbnail). If the document contains multiple images,{{ item.Images }}An image URL array will be returned, you can iterate through it again to display.
  • Category information:{{ item.CategoryId }}(Category ID). To get the category name or link, you usually need to combinecategoryDetailTags such as{% categoryDetail with name="Title" id=item.CategoryId %}.
  • **Custom field

Related articles

How to set up independent templates for specific documents, categories, or single pages to control their display styles?

In AnQiCMS, setting up independent templates for specific documents, categories, or single pages is a key feature for achieving personalized content display and enhancing user experience on the website.This not only makes the website design more flexible, but also allows for precise style control for different types of content, thus better satisfying the brand positioning and content operation strategy.### Understanding AnQiCMS Template Mechanism AnQiCMS provides two main ways to apply custom templates: one is that the system automatically identifies and loads templates based on file naming rules

2025-11-08

What is the directory structure of AnQiCMS templates, and how to organize template files for efficient display?

Build and manage website templates in AnQiCMS, the first step is to understand its unique directory structure and file organization.This not only concerns the visual presentation of the website, but also affects the performance, maintainability, and future scalability of the website.A clear and reasonable template organization strategy can greatly improve the work of content operation and front-end development.### Overview of AnQiCMS Template System AnQiCMS uses a syntax similar to the Django template engine, with `.html` as the template file suffix, which allows developers familiar with this template language to get started quickly

2025-11-08

What are the basic conventions to follow when making AnQiCMS templates to ensure correct content display?

Build a website template in AnQiCMS, as if designing a beautiful appearance and a practical functional framework for the website.Ensure that the carefully designed content is accurately displayed to visitors, it is crucial to follow some basic template design conventions.These conventions can not only help you efficiently complete template development, but also ensure the stability of the website and the convenience of future maintenance. ### One, the organization and coding specifications of template files Firstly, AnQiCMS has clear requirements for the **location and naming** of template files. All template files should be written with `

2025-11-08

How does AnQiCMS improve website content loading speed and user display experience through static caching?

In today's fast-paced digital world, website loading speed directly affects the first impression and the time spent by users on the website.A fast-loading website not only enhances user experience but is also one of the key factors in search engine optimization (SEO).AnQiCMS deeply understands this point, and has built-in powerful static caching mechanisms, aiming to fundamentally improve your website's performance and user experience. ### Understanding Static Caching: The Secret Weapon of Website Acceleration Imagine that your website is a bustling café.Each time a customer orders coffee (visits a page)

2025-11-08

How is the `archiveDetail` tag used to retrieve and display detailed content information for a single document?

In AnQi CMS, the `archiveDetail` tag is a very core and practical tool for template creation, mainly used to retrieve and display detailed content information of a single document.Whether it is a blog post, product details, news report, or any other page content that needs to be independently displayed, `archiveDetail` can help you flexibly extract and present it on the website's front-end page.### `archiveDetail` Tag Core Function Overview The purpose of this tag is to provide rich data support for a single document

2025-11-08

How to use `categoryList` and `categoryDetail` tags to build and display category navigation and details?

In website content management, category navigation and detail pages are the core paths for users to browse the website and obtain information, as well as an important basis for search engines to understand the website structure.A clear and intuitive classification system not only greatly enhances the user experience, but also effectively helps the website's SEO performance.For users of Anqi CMS, flexibly using the `categoryList` and `categoryDetail` template tags provided by the system can easily build powerful, beautiful, and practical classification navigation and detail display.--- ### One

2025-11-08

How do the `pageList` and `pageDetail` tags manage and display the single-page content of a website?

In website operation, single-page content (such as "About Us", "Contact Information", "Service Introduction", etc.) plays a crucial role.They are usually carriers that display the core information of a company, brand story, or specific service details.To efficiently manage and display these pages, AnQiCMS provides the `pageList` and `pageDetail` two core tags, making content organization and presentation both flexible and convenient.### Back-end management of single-page content In AnQiCMS back-end

2025-11-08

How to display the `tagList` and `tagDataList` tags showing the website tags and related document list?

In website operation, a tag (Tag) is an extremely useful content organization tool.They can not only help users find the content they are interested in faster, improve the user experience of the website, but also optimize the search engine's crawling and understanding of the website content, and have a positive effect on SEO performance.The AnQi CMS provides website administrators with a powerful and flexible tag management feature, through the `tagList` and `tagDataList` template tags, we can easily display tag lists and documents related to specific tags on the website.###

2025-11-08