How to filter the document list based on category ID, model ID, or recommendation attributes for the `archiveList` tag?

Calendar 👁️ 68

In AnQiCMS, flexibly displaying content is one of the keys to building an efficient website.archiveListIt is such a powerful tool that allows us to filter and display the document list of the website according to various conditions. Whether you want to display a certain type of article on a specific page or organize information based on content type or editor's recommendation,archiveListProvide precise control.

Accurate positioning: Filter document list according to category ID.

When we want to display documents under a specific category in a certain area of the website, such as the sidebar or a special topic page,categoryIdThe parameter is put to good use. This parameter allows us to specify one or more category IDs, thus accurately extracting all documents under these categories.

For example, if you want to display the articles under the "Company News" category with ID 1, you can use it like this:

{% archiveList archives with categoryId="1" limit="5" %}
    {# 在这里循环展示文档 #}
{% endarchiveList %}

If your content spans multiple categories, for example, if you want to display documents under both 'Company News' (ID 1) and 'Industry News' (ID 3), just separate these IDs with a comma:

{% archiveList archives with categoryId="1,3" limit="10" %}
    {# 结合多个分类ID展示文档 #}
{% endarchiveList %}

It is worth noting that the AnQiCMS category can have a hierarchical relationship. By default, when you specify a parent category ID,archiveListIt will automatically include all documents under its subcategories. But if you only want to display the documents of the current specified category (excluding its subcategories), you can by settingchildthe parameter tofalseto achieve:

{% archiveList archives with categoryId="1" child=false limit="5" %}
    {# 只展示ID为1分类下的文档,不包含其子分类 #}
{% endarchiveList %}

Moreover, in certain special page scenarios, we may wisharchiveListNot to automatically inherit the category ID of the current page, but to specify it manually. At this point, we cancategoryIdSet explicitly"0"Avoid any automatic inheritance behavior.

Content division: Filter document list according to model ID

The "Content Model" feature of AnQiCMS is a reflection of its high flexibility.It allows us to define different types of content structures, such as 'article model', 'product model', and even 'case model'.When we need to distinguish between different types of content and display it on the front end,moduleIdParameters are particularly important.

By specifyingmoduleIdWe can ensurearchiveListOnly extract documents that belong to a specific content model. For example, if the 'article model' ID is 1 and the 'product model' ID is 2, then we can do it like this:

Want to display the latest 5 articles:

{% archiveList articles with moduleId="1" order="id desc" limit="5" %}
    {# 展示最新的5篇文章 #}
{% endarchiveList %}

If you want to list all the products:

{% archiveList products with moduleId="2" type="page" limit="10" %}
    {# 列出所有产品,并支持分页 #}
{% endarchiveList %}

This model-based filtering method makes the website's content structure clearer, and it is also convenient for differentiated display and management for different content models.

Highlight the key points: Filter the document list based on recommended attributes

In addition to categories and models, AnQiCMS also provides a "recommendation attribute" feature that allows content operators to mark documents with special tags to achieve the effect of highlighting such as "headlines", "recommendations", and "slides."}flagParameters are used to take advantage of these recommendation attributes for filtering.

AnQiCMS supports various recommendation attributes, each with a corresponding letter identifier, such as:

  • h: Headlines
  • c: Recommendations
  • f: Slides
  • a: Special Recommendations
  • s: Scroll
  • p: Image
  • j: Jump

When you want to display documents marked as "slideshow" in the home page slideshow area, you can set it like thisflagparameters:

{% archiveList slides with flag="f" limit="3" %}
    {# 展示3篇被标记为“幻灯”的文档 #}
{% endarchiveList %}

You can also filter out documents with multiple recommended properties, such as documents that are both 'recommended' and 'images', although usually only one main property is used:

{% archiveList featuredImages with flag="c,p" limit="4" %}
    {# 展示4篇既是“推荐”又是“图片”的文档 #}
{% endarchiveList %}

withflagCorrespondinglyexcludeFlagIf you want to exclude documents with certain recommended properties, such as not displaying any "top" content, you can use it like this:

{% archiveList regularContent with excludeFlag="h" limit="10" %}
    {# 展示除了“头条”之外的10篇文档 #}
{% endarchiveList %}

Combined use to achieve more refined filtering

archiveListThe strength of the tag lies in the fact that these filtering conditions are not mutually exclusive, but can be flexibly combined. By specifying at the same timecategoryId/moduleIdandflagWe can build a very specific list of documents.

For example, if you want to display the latest 10 documents under the "article model" with ID 1, category ID 5, and marked as "recommended", you can combine these parameters in this way:

{% archiveList targetedArticles with moduleId="1" categoryId="5" flag="c" order="id desc" limit="10" %}
    {# 精准筛选:文章模型,分类ID为5,推荐属性,最新10篇 #}
{% endarchiveList %}

Moreover, for users who use the AnQiCMS multi-site management function, they can alsositeIdParameters to specify the document list under which site to retrieve, ensuring flexible content calls in multi-site environments.

Through the flexible use of these parameters,archiveListTags can help us accurately control the display of website content, whether it is to improve user experience or to optimize search engine rankings, it can provide strong support.


Frequently Asked Questions (FAQ)

1. I want to display the latest documents under a certain category on a page, and these documents must be of the "article model", how should I write it?

You can combinecategoryId/moduleIdandorderImplement the parameter. Assume the category ID is 5, and the article model ID is 1:

{% archiveList recentArticles with categoryId="5" moduleId="1" order="id desc" limit="5" %}
    {# 在这里循环展示最新5篇“文章模型”下的分类5文档 #}
{% endarchiveList %}

2. How to avoidarchiveListIs it to automatically obtain the category ID of the current page, but to filter completely according to the ID I specify?

You cancategoryIdThe parameter is explicitly set to"0", like thisarchiveListIt will not attempt to read the category information of the current page, but will only use other filtering conditions you manually specify (or do not specify).

{% archiveList myCustomList with categoryId="0" moduleId="1" limit="10" %}
    {# 确保不继承当前页面的分类ID,只展示模型ID为1的文档 #}
{% endarchiveList %}

3. Can I exclude all documents marked as 'Headline' from a list while also displaying content from a specific category?

Of course you can. You can use it at the same timecategoryIdandexcludeFlagParameter. Assuming the category ID is 10, the headline attributes to be excluded areh:

{% archiveList filteredList with categoryId="10" excludeFlag="h" limit="8" %}
    {# 展示分类ID为10,且不是头条的8篇文档 #}
{% endarchiveList %}

Related articles

How to get the global configuration information of AnQiCMS template, such as the website name and logo?

In AnQiCMS template, cleverly obtain the global configuration of the website to make your website more flexible When designing or maintaining an AnQiCMS website template, we often encounter a need: to display unified global information on each page of the website, such as the name of the website, logo, filing number, or custom contact information.Manually adding this information to each page is not only inefficient but also time-consuming and laborious to update once it needs to be changed.

2025-11-08

How does AnQiCMS increase the level of content operation automation through the timed publishing function?

Today, with the increasing emphasis on efficiency and user experience, the degree of automation in content operation is directly related to the competitiveness of the website.For many small and medium-sized enterprises and self-media operators, how to ensure high-quality, frequent, and precise targeting of content under limited human resources is a continuous challenge.AnQiCMS is an efficient and flexible content management system, and its built-in timed publishing function exactly provides strong support for solving this problem.Imagine such a scenario: You have meticulously planned marketing content for a week or even a month, including articles, product updates, and event previews.

2025-11-08

How to implement multi-language content switching and display in AnQiCMS template?

In today's digital world, your website may need to be global for users.AnQiCMS fully understands this requirement and provides powerful multilingual support functions, allowing you to easily build and manage multilingual websites and better serve users from different countries and regions.How to implement multi-language content switching and display in AnQiCMS templates?Let's explore step by step. ### Understanding the multi-language mechanism of AnQiCMS: Handling two types of 'languages' In AnQiCMS, we need to distinguish between two types of 'language' content

2025-11-08

How to configure a separate domain and database information for a new site in AnQiCMS multi-site management?

AnQiCMS with its efficient and flexible multi-site management function provides great convenience to users, especially in scenarios where independent sites need to be built for different brands, products, or services.When you want to configure a separate domain and database information for a new site, AnQiCMS provides a clear and practical management process.This not only helps to isolate and secure the data, but also allows each site to have more independent operation and optimization space.### Understand the value of independent configuration for multiple sites Before discussing the specific operations

2025-11-08

How to create a multi-level category navigation and display its subcategories or related documents in AnQiCMS template?

Build flexible multi-level category navigation and content display in AnQiCMS template Effective organization of website content is crucial for providing a good user experience and improving search engine visibility.Whether it is a corporate website, product display, or self-media blog, a clear multi-level classification navigation can help users quickly find the information they need and is also conducive to search engines understanding the structure of the website.AnQiCMS as an efficient and customizable content management system provides flexible template tags, allowing us to easily implement complex multi-level classification navigation and content display. Next

2025-11-08

How to display comment content and user status for the `commentList` label in AnQiCMS?

Build a highly interactive website in AnQiCMS, the comment function is undoubtedly the key to increasing user engagement.The `commentList` tag is a great tool provided by AnQiCMS for this purpose, it can help website developers and operators flexibly display comment content, and clearly present the status of commenters, allowing visitors to grasp the dynamics of the comment area at a glance.### Core Feature Overview: Basic Usage of `commentList` Tag The `commentList` tag is mainly used to retrieve the comment list of a specified document

2025-11-08

How to enable and use the captcha feature of the留言表单in AnQiCMS?

The website guestbook is a good place to interact with visitors, which brings the website closer to the users.However, without proper protection, the message board will soon be overwhelmed by various spam, malicious submissions, and even automated scripts, which not only affects the cleanliness of the website but may also consume server resources and even damage the reputation of the website.Fortunately, AnQiCMS provides a simple and effective solution: the captcha feature.

2025-11-08

How to use the `archiveFilters` tag in AnQiCMS to achieve combined filtering of document parameters?

## Mastering AnQiCMS: The Art of Using `archiveFilters` Tag for Document Parameter Combination Filtering It is crucial to provide users with accurate and efficient content search experience in content operation.Imagine if your website has a rich variety of content, but users find it difficult to quickly find the information they need. This will undoubtedly greatly affect user experience and the conversion rate of the website.

2025-11-08