How to precisely filter and display a document list with specific categories, models, or recommended attributes using the `archiveList` tag?

Calendar 👁️ 69

In AnQi CMS,archiveListTags are the core tools for building dynamic content lists, allowing you to flexibly extract and display the content you want from the document library of the website. Whether it's displaying the latest articles under a specific category, popular products under a specific content model, or special document series with specific recommendation attributes, archiveListCan be achieved through its rich parameter configuration, helping you to accurately meet these needs.

Accurately locate content: categories, models and recommended attributes

Firstly, let's understandarchiveListThe most commonly used dimensions for filtering content: classification, content model, and recommendation properties.

1. Filter documents by category (categoryId)

The content of a website is usually categorized into different categories according to its theme, such as "Company News", "Industry Dynamics", or "Product Introduction", etc.archiveListTags can be used tocategoryIdParameters allow you to easily specify which or which categories of documents to display.

  • Specify a single or multiple categoriesIf you want to display documents under a specific category (for example, ID 10), you can use it like this:{% archiveList archives with categoryId="10" %}If you need to display documents under multiple categories (such as IDs 10, 12, 15), just separate them with commas:{% archiveList archives with categoryId="10,12,15" %}.
  • Control subcategory contentIn some cases, you may only want to display the documents of the current category itself, without including the content of its subcategories. In this case,child="false"the parameter comes into play. By default,archiveListIt will include sub-categories. If you only want the documents of the current category (ID 10), you can write it like this:{% archiveList archives with categoryId="10" child="false" %}.
  • It does not depend on the current page category: Sometimes, even if you are on the category page, you may not wantarchiveListto automatically read the category ID of the current page. At this time, you can explicitly setcategoryId="0"Stop this automatic behavior and specify the category ID you need to filter.

2. Filter documents by content model (moduleId)

The key feature of Anqi CMS is its flexible content model mechanism, which allows you to define independent field structures for different types of content (such as articles, products, cases, etc.).archiveListTag throughmoduleIdParameters, allow you to accurately filter out documents belonging to a specific content model.

  • Identify the content modelIn the Anq CMS backend, you can create content models for different content types (for example, the system default "article model" and "product model").Each content model has a unique ID. By specifying this ID,archiveListOnly documents under the model can be displayed. For example, if you want to display documents under the product model and the product model ID is 2, you can use it like this:{% archiveList products with moduleId="2" %}.
  • Combine categories and modelsYou can also usemoduleIdandcategoryIdCombined use, for example, to display a list of products under a certain category that belong to a product model.

3. Filter documents by recommended attributes (flag)

When publishing documents, AnQi CMS provides various recommended attributes such as "headline", "recommended", "slide" etc., which are identified by different letters (for example,hrepresenting the headline,cRepresents recommendation).archiveListTags can be used toflagParameters, filter content based on these properties.

  • Specify recommendation properties: If you want to display all documents marked as 'recommended' on the homepage, you can use it like this:{% archiveList featuredDocs with flag="c" %}You can combine multiple properties, for exampleflag="h,c"Documents that are both headlines and recommended will be displayed.
  • Exclude specific attributes: If you want to exclude documents with certain specific properties, you can useexcludeFlagthe parameters. For example,{% archiveList normalDocs with excludeFlag="h" %}It will display all non-headline documents.
  • Display attribute identifier: If you need to display the recommended attributes of documents in the list, you canarchiveListthe tag withshowFlag="true"Parameter.

Expand filtering capabilities: more practical parameters

In addition to the above core filtering criteria,archiveListit also provides a variety of other parameters to further optimize your content list:

  • Sort method (order)You can sort the documents according to document ID (latest released), views (most popular), or custom sorting on the backend. For example,order="id desc"means in descending order by ID (latest release),order="views desc"means sorted by views in descending order.
  • Show number and pagination (limit,type="page"):limitParameters are used to control how many documents are displayed. If you need to implement pagination, you can usetypethe parameter to"page"and combiningpaginationtags to create a complete pagination navigation.
  • When searching for keywords (q): on the search results page,qThe parameter can be used to match the content of the document title that contains specific keywords. If the URL already containsqparameter,archiveListit will be automatically read and applied.
  • Custom Filter Parameter: AnQi CMS allows you to define custom fields for content models in the background. If these fields are set to be filterable,archiveListYou can further filter based on the query parameters in the URL, which is very useful for creating highly customized filter interfaces (such as property websites filtering by area, type, etc.). You can combinearchiveFiltersTags to build these filtering conditions.
  • Multi-site data call (siteId): If you use the multi-site management function of Anqi CMS,siteIdthe parameter allows you to call data from other sites.
  • Combination document display (combineId,combineFromId)This is an advanced usage, used to display multiple documents in a list, such as showing 'Travel routes from A to B', which can dynamically combine document titles and links, often used in scenarios of comparison or combination of information.

Example of practical application scenarios

Let us go through several common scenarios and seearchiveListhow tags play a role:

Scenario one: Display the latest 5 company news on the homepage

Assuming the 'Company News' category ID is 10 and it belongs to the 'Article Model' (ID 1).

<div class="latest-news">
    <h2>最新公司新闻</h2>
    <ul>
        {% archiveList news with moduleId="1" categoryId="10" limit="5" order="id desc" %}
            {% for item in news %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    <span>发布日期:{{ stampToDate(item.CreatedTime, "2006-01-02") }}</span>
                </li>
            {% empty %}
                <li>暂无公司新闻。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Scenario two: Display popular recommended products in the sidebar.

Assuming the ID of the "product model" is 2 and the product is marked as "recommended" (c)

<div class="hot-products">
    <h3>热门推荐产品</h3>
    <ul>
        {% archiveList hotProducts with moduleId="2" flag="c" limit="3" order="views desc" %}
            {% for item in hotProducts %}
                <li>
                    <a href="{{ item.Link }}">
                        <img src="{{ item.Thumb }}" alt="{{ item.Title }}">
                        {{ item.Title }}
                    </a>
                </li>
            {% empty %}
                <li>暂无推荐产品。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>
</div>

Scenario three: Display the list of articles under the current category and its subcategories on the category page, and support pagination

Assuming the article model ID is 1 and in the template of the category page,archiveListit will automatically retrieve the current category ID.

<div class="category-articles">
    <h1>{% categoryDetail with name="Title" %}</h1> {# 显示当前分类标题 #}
    <ul>
        {% archiveList articles with moduleId="1" type="page" limit="10" order="id desc" %}
            {% for item in articles %}
                <li>
                    <a href="{{ item.Link }}">{{ item.Title }}</a>
                    <span>所属分类:{% categoryDetail with name="Title" id=item.CategoryId %}</span>
                    <span>阅读量:{{ item.Views }}</span>
                </li>
            {% empty %}
                <li>当前分类下暂无文章。</li>
            {% endfor %}
        {% endarchiveList %}
    </ul>

    {# 分页导航 #}
    {% pagination pages with show="5" %}
        <div class="pagination-nav">
            {% if pages.PrevPage %}<a href="{{ pages.PrevPage.Link }}">上一页</a>{% endif %}
            {% for item in pages.Pages %}
                <a href="{{ item.Link }}" class="{% if item.IsCurrent %}active{% endif %}">{{ item.Name }}</a>
            {% endfor %}
            {% if pages.NextPage %}<a href="{{ pages.NextPage.Link }}">下一页</a>{% endif %}
        </div>
    {% endpagination %}
</div>

By using these flexible parameter combinations,archiveListTags can help you build highly customized and powerful content lists to meet various display needs.


Frequently Asked Questions (FAQ)

1. How toarchiveListCan multiple filter conditions be applied in tags?

You can inarchiveListLabel parameters can be added directly, and the system will automatically combine these conditions to filter. For example, if you want to get the "article model" (moduleId="1") under the "Company News" category (categoryId="10") with the "Recommended" attribute (flag="c"Here is how you can write the latest 5 articles, {% archiveList news with moduleId="1" categoryId="10" flag="c" limit="5" order="id desc" %}.

2.archiveListWhich pages on the website can use the tags?

archiveListLabels can theoretically be used in any template file on the website (such as the homepage, category page, detail page, search results page, custom page, etc.). When you use it on a non-category page or non-model page, you may need to specify it more clearly.moduleIdorcategoryIdParameters such as this are not displayed on the category page or model page

Related articles

How to dynamically display data using Django-style tags and variables in AnQiCMS templates?

AnQiCMS provides a flexible and powerful template system, which adopts a syntax style similar to the Django template engine, making experienced developers able to get started quickly, and it is also very intuitive, even users who are not familiar with template language can dynamically present website content through simple learning.This system, with its concise labels and variable usage, makes data interaction with the front-end page efficient and easy to manage.To fully utilize the AnQiCMS template for dynamic data display, we need to understand its core syntax structure: variables, tags, and filters

2025-11-07

How to choose and apply the adaptive, code adaptation, PC+mobile terminal template mode supported by AnQiCMS?

How to ensure that the content is presented elegantly and efficiently on various devices when building and operating a website is a challenge that every operator has to face.AnQiCMS as a feature-rich enterprise-level content management system, fully considers this point, and provides three flexible template modes of adaptive, code adaptation, and independent sites for PC and mobile phones, allowing us to make **choices according to actual needs.Next, we will delve into the characteristics, application scenarios, and how to configure and use these three modes in AnQiCMS

2025-11-07

What are the specific conventions for naming template files and directory structures when creating templates in AnQiCMS?

AnQiCMS is a content management system renowned for its efficiency and flexibility, also has a clear set of conventions in template design, aiming to help developers and operators build websites with clear structures and easy maintenance.Understanding these conventions is a key step to efficiently using AnQiCMS for website customization and content display. ### Core conventions of template files The template files of AnQiCMS use the `.html` extension as the suffix.This convention makes the file type clear at a glance and also helps the editor with syntax highlighting and intelligent hints

2025-11-07

How does the modular design of AnQiCMS support personalized customization and secondary development requirements?

The choice of a content management system (CMS) focuses on flexibility and scalability, which is a core concern for many businesses and individual users.AnQiCMS (AnQiCMS) stands out with its unique modular design, demonstrating significant advantages in supporting personalized customization and secondary development, allowing users to create powerful and distinctive websites according to their own needs. ### The Foundation of Modular Design: The Elasticity of Core Architecture Anqi CMS is developed in Go language, which choice itself brings high performance and high concurrency advantages to the system. It is more important

2025-11-07

How to retrieve the title, content, image, and custom fields of a specific document using the `archiveDetail` tag?

How to use the `archiveDetail` tag in AnQiCMS to finely control the display of document content?AnQiCMS as an efficient and flexible content management system, one of its core advantages lies in its powerful content display capabilities.For each independent article, product detail, or any other 'document' type of content on the website, we hope to fine-tune their display methods on the front page.This is the place where the `archiveDetail` tag really shines.

2025-11-07

How to implement hierarchical display and nested calling of the `categoryList` tag?

Building a clear and organized website navigation in AnQiCMS is crucial for improving user experience and website accessibility, especially when dealing with multi-level categories.The `categoryList` tag was created for this purpose, providing powerful features to help us flexibly display the hierarchical structure of categories and make fine-grained nested calls.

2025-11-07

How to use the `prevArchive` and `nextArchive` tags to navigate to adjacent documents in the article detail page?

In today's content-driven world, the user experience of the website article detail page is particularly important.When a reader is immersed in an excellent content, if they can navigate smoothly to related or adjacent articles, not only can it extend their stay on the website and increase the page views, but it can also indirectly optimize the search engine crawling and ranking through the internal link structure.AnQi CMS is an efficient and SEO-friendly content management system that fully considers these details and provides simple and intuitive template tags to help us easily achieve this function. Today

2025-11-07

How to get and paginate the display of all relevant documents under a specific `tagDataList` tag?

When managing content in Anqi CMS, tags (Tag) are an important tool for organizing and categorizing information.It can not only help users quickly find relevant content, but also significantly improve the internal link structure and SEO performance of the website.When it is necessary to display all relevant documents under a specific tag and to manage pagination, the `tagDataList` tag becomes an indispensable core function.

2025-11-07