How to use the `archiveList` tag of AnQiCMS to get the document list under a specified content model?

Calendar 👁️ 56

AnQiCMS content management: usingarchiveListPrecisely obtain the document list with tags

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its ability to organize and display content. In the AnQiCMS, a high-efficiency and flexible Go language content management system,archiveListTags are undoubtedly a powerful weapon in the content display process.It is not just a simple content call tag, but also a key bridge connecting your website content model with the front-end display logic.archiveListLabel, accurately and efficiently retrieve the document list under the specified content model.

archiveList: The core of AnQiCMS content display.

AnQiCMS is inv2.1.1An important label restructuring was performed in the version, removing the originalarticleandproductand specific labels were introduced uniformlyarchiveThe series of tags, and fully embraced the concept of Content Model.This means that all articles, products, and even any content type you customize are uniformly classified as "documents (archive)" and distinguished and managed through their respective content models.archiveListTags are the core of this system, allowing you to flexibly display the document list you need on the website front-end based on different content models, categories, attributes, and other conditions.

Its strength lies in the ability to dynamically load and display content on different page templates (such as the homepage, list page, special page) according to business needs, whether it is news articles, product introductions, event information, or case studies.archiveListCan do it effortlessly.

Core parameter analysis: accurately locate your content.

To usearchiveListLabel, you need to wrap it in aforIn a loop, because its purpose is to return a collection of documents. The basic structure is as follows:

{% archiveList archives with ... %}
    {% for item in archives %}
        {# 在这里展示每个文档的具体信息 #}
    {% empty %}
        {# 如果列表为空,则显示此内容 #}
    {% endfor %}
{% endarchiveList %}

Among them,archivesis the variable name you define for the document list,itemIt represents the variable for each document in the loop.withThe parameters behind it are the key to accurately locate the content.

  1. moduleId- Content model, the cornerstone of documents moduleIdIsarchiveListA parameter that is crucial in the label.It explicitly tells the system which content model you want to retrieve the document from.AnQiCMS allows you to customize content models, for example, you can create 'article models', 'product models', 'case models', etc.

    • How to obtainmoduleId?In the AnQiCMS backend, go to 'Content Management' -> 'Content Model', and you will see that each model has a unique ID. For example, the default 'Article Model' usually has an ID of1,“Product model”usually has an ID of2.When customizing a model, you can also record the corresponding ID.
    • Example:If you want to get the document list under all article models, you can write it like this:moduleId="1".
  2. categoryId- Accurately locate the classification of contentWhen there are multiple classifications under your content model,categoryIdParameters can help you further narrow down the scope, only fetching documents under specified categories or multiple categories.

    • Example:Get the category ID of5article list:categoryId="5" moduleId="1".
    • Multiple categories:Get the category ID of5/6/7article list:categoryId="5,6,7" moduleId="1".
    • Current category:If not specifiedcategoryId,archiveListThe default behavior is to try to read the category ID of the current page. If you want it not to read the current category automatically, you can explicitly setcategoryId="0".
    • Exclude categories:UseexcludeCategoryId="8"You can exclude ID as8documents under the category.
  3. type- The diversity of list presentation. typeThe parameter defines what you want.archiveListHow to return document data, it has several common values:

    • type="list"(Default): Get a fixed number of document lists, usually used for sidebar recommendations, latest content on the homepage, etc.
    • type="page": Used for displaying document lists with pagination. When using this type, you need to配合paginationtags to generate pagination navigation.
    • type="related": Used to retrieve the document list related to the current document.This is commonly used on the document detail page, AnQiCMS will automatically match related content based on the current document's category, keywords, etc.like="keywords"orlike="relation"Further refine related rules.
  4. orderandlimit- Sorting and quantity control of results

    • order:Control the sorting method of documents. Common values include:
      • order="id desc":Sort by document ID in reverse order (latest released).
      • order="views desc":Sort by views in reverse order (most popular).
      • order="sort desc": Sort by custom backend (default).
    • limit:Control the number of documents retrieved.
      • limit="10": Retrieve 10 documents.
      • limit="2,10"Starting from the 2nd item, retrieve 10 documents (often used to skip the first few).
  5. Other commonly used parameters: finer filtering

    • flag:Based on the recommended properties of the document (such as头条h, recommendedcof slidesffiltered. For exampleflag="c"Get recommended documents.
    • q:Search keywords. Only intype="page"it is effective, and can be used for fuzzy search in document titles.
    • siteId:Under the multi-site management mode, specify which site's data to retrieve. Generally, it is not necessary to fill in.
    • child="false":By default,archiveListIt will simultaneously retrieve documents under the specified category and its subcategories. If you only want to retrieve documents under the current category, you can setchild="false".
    • userId/parentId/combineId/combineFromId:Used for more professional filtering needs, such as by author, parent document, combined document, etc.

Practical exercise:archiveListApplication scenarios

Now, let's show several common application scenarios through several examples.archiveListThe powerful function.

Scenario one: Display the latest published article list on the homepage.

Assuming your article model ID is.1.

`twig

<h2>最新文章</h2>
<ul>
    {% archiveList archives with moduleId="1" type="list" order="id desc" limit="8" %}
        {% for item in archives %}
        <li>

Related articles

`archiveFilters` label can be combined with AnQiCMS's multilingual support to provide multilingual filtering conditions?

As an experienced website operations expert, I have accumulated rich experience in the content management and operations practice of AnQiCMS.Today, we will delve into a commonly discussed issue by users: Can AnQiCMS's `archiveFilters` tag be combined with multilingual support to provide multilingual filtering conditions?To answer this question, we need to understand the multilingual mechanism of AnQiCMS and the working principle of the `archiveFilters` tag.AnQiCMS as an enterprise-level content management system

2025-11-06

How will the `archiveFilters` tag display and handle if a document belongs to multiple filter parameter values?

## AnQi CMS `archiveFilters` tag: How will it elegantly present when a document meets multiple filter conditions?As an experienced website operations expert, I am well aware that the discoverability of content is crucial for user experience and SEO.AnQiCMS provides many powerful and flexible features in content management, among which the `archiveFilters` tag is undoubtedly a powerful tool for building advanced filtering interfaces and improving content navigation efficiency.

2025-11-06

Does the `archiveFilters` tag support controlling the sorting method for custom parameters?

As an experienced website operations expert, I have a deep understanding of AnQiCMS's functional and content operation strategies.Today, we will discuss a question that many users may be concerned about: Does the `archiveFilters` tag support controlling the sorting method of custom parameters?

2025-11-06

How to handle user prompts when the filtering result is empty when using `archiveFilters` tag?

## Optimize the empty result prompt of the `archiveFilters` tag in AnQiCMS, improve user experience In the template development of AnQiCMS, the `archiveFilters` tag is undoubtedly a powerful tool for building flexible content filtering functions.It allows us to provide users with dynamic filtering options based on predefined document parameters, thus helping users quickly locate the content they are interested in.However, whether the filter options themselves are empty, or the user applies filter conditions and does not find matching content, these two 'empty result' states if not handled properly

2025-11-06

How to filter and display documents based on multiple category IDs for the `archiveList` tag?

As an experienced website operations expert, I fully understand that the flexibility of a content management system is crucial for efficient operations.AnQiCMS (AnQiCMS) provides us with great convenience with its powerful template tag system.Today, let's delve deeply into a very practical feature: how to use the `archiveList` tag to filter and display documents based on multiple category IDs, thereby creating more targeted and attractive content modules.

2025-11-06

How to exclude documents of a specific category in `archiveList` to display accurate content?

As an experienced website operations expert, I am well aware of the importance of accurate content display for user experience and website operation efficiency.In a content management system, we often encounter the need to exclude certain specific categories of documents when generating article lists, in order to ensure the relevance and focus of the content.AnQiCMS (AnQiCMS) is an efficient and flexible content management tool that provides us with a very convenient solution.

2025-11-06

How to use the `archiveList` tag to get documents with specific recommended attributes (such as "Top Stories" or "Slideshow")?

As an experienced website operations expert, I am well aware of the core value of a content management system (CMS) in terms of its flexibility and content scheduling capabilities.AnQiCMS (AnQiCMS) boasts its efficient architecture based on the Go language and rich features, providing strong support for content operations.Today, let's delve into a very practical scenario in content operation: how to accurately obtain and display documents with specific recommendation attributes using the `archiveList` tag, such as the website's 'headlines' news or important content for the 'slideshow' carousel.

2025-11-06

How to implement sorting of the document list by views or publication time using the `archiveList` tag?

As an experienced website operations expert, I know that the core value of a content management system (CMS) lies in its flexibility and the efficiency of content presentation.AnQiCMS (AnQiCMS) excels in this aspect with its efficient architecture in the Go language and a rich set of features.Today, let's delve deeply into a function that is extremely commonly used in content operation: how to use the `archiveList` tag to sort the document list by views or publication time.Content sorting seems simple, but it actually contains profound operational strategies.

2025-11-06