How to filter and display the document list based on categories, models, recommended attributes, and other conditions?

Calendar 👁️ 79

Today, with the increasing refinement of content management, how to make the document list of a website flexible to display according to different needs is a core skill that every website operator needs to master.AnQiCMS (AnQiCMS) takes advantage of its powerful template tag system, providing us with an extremely convenient and efficient solution.This article will delve into how to accurately filter and display your document list in AnQiCMS based on various conditions such as categories, content models, recommendation attributes, and more.


Core tool:archiveListTag

In AnQiCMS, we mainly use powerfularchiveListThe template tag controls the display of the document list. This tag provides rich parameters, allowing you to build various complex filtering conditions like building Lego blocks according to specific needs.Whether it is to display the latest articles, hot products, or content on specific themes,archiveListCan easily handle.

One, filter document list by category

Website content is usually organized into different categories, such as "Company News", "Industry Dynamics", "Product Cases", and so on. When you want to display documents under a specific category on the page, archiveListlabel'scategoryIdThe parameter is your preference.

  • Specify a single category:You just need to assign the ID of the required category tocategoryIdthe parameter. For example,categoryId="1"Only documents under the category with ID 1 will be displayed.
  • Specify multiple categories:If you want to display documents from multiple categories in the same list, just separate the category IDs with English commas, for example:categoryId="1,2,3".
  • Include subcategories:AnQiCMS is default to intelligently display the documents of the current category and all its subcategories. If you want to focus only on the current category itself and exclude its subcategories, you can explicitly setchild="false".
  • Exclude a specific category:If you want to display all documents within a certain range but exclude one or two unrelated categories,excludeCategoryIdthe parameter can be used, such asexcludeCategoryId="5".

Example code snippet:

{# 显示ID为1的分类下的最新10篇文章,包含子分类 #}
{% archiveList articles with categoryId="1" order="id desc" limit="10" %}
    {% for item in articles %}
        <li><a href="{{item.Link}}">{{item.Title}}</a></li>
    {% endfor %}
{% endarchiveList %}

Second, filter the document list according to the content model

Flexible content model design of Anqi CMS, allowing you to easily manage articles, products, events, and other types of content.In certain scenarios, you may want to display data from different content models on a single page. At this point,moduleIdParameters are particularly important.

  • Specify a particular model:Each content model has a unique ID. For example, the article model may have an ID of 1, and the product model may have an ID of 2. You canmoduleId="1"to get all articles, ormoduleId="2"Get all products.

Imagine, your website has both technical articles and product introductions, you may want to display them in different areas of the homepage.moduleIdIt can help you clearly separate different types of content.

Example code snippet:

{# 显示所有产品模型下的最新5个产品 #}
{% archiveList products with moduleId="2" order="id desc" limit="5" %}
    {% for item in products %}
        <li>
            <img src="{{item.Thumb}}" alt="{{item.Title}}">
            <a href="{{item.Link}}">{{item.Title}}</a>
        </li>
    {% endfor %}
{% endarchiveList %}

3. Filter document list according to recommended attributes (Flag)

AnQi CMS provides a series of recommended attributes (Flag) that allow you to mark important content, such as "Headline", "Recommended", "Slideshow", and so on.These tags can be easily set in the background when editing documents and are an excellent tool for enhancing content visibility and management flexibility.

  • Specify recommended attributes:You can use it toflagParameters to filter documents with specific recommendation attributes. Common attribute values include:
    • h: Headlines
    • c: Recommendations
    • f: Slides
    • a: Special Recommendations
    • s: Scroll
    • p: Image
    • j: Go to You can use a single attribute, such asflag="c"to get all recommended content; you can also combine them, such asflag="h,f"to get content that is both headlines and slides.
  • Exclude recommended properties:Similarly, if you want to avoid certain specific properties from appearing in the list,excludeFlagthe parameter can help you exclude.

Example code snippet:

{# 显示带有“幻灯(f)”属性的最新3篇文档 #}
{% archiveList slides with flag="f" order="id desc" limit="3" %}
    {% for item in slides %}
        <div class="carousel-item">
            <img src="{{item.Logo}}" alt="{{item.Title}}">
            <h3>{{item.Title}}</h3>
        </div>
    {% endfor %}
{% endarchiveList %}

4. Combination filtering and advanced applications

These filtering conditions do not operate independently, you can combine them cleverly according to your actual needs to achieve a more refined document list display.

  • Sorting method (order):You can specify the document sorting rules, for exampleorder="views desc"Sorted by view count from high to low, i.e., popular documents,order="id desc"Sorted by publication time from new to old, i.e., the latest documents,order="sort desc"(Sorted by custom sorting in the background).
  • Display number and pagination(limitwithtype):
    • limit="10": Used for a fixed number of lists, such as displaying the latest 10 articles in the sidebar.
    • type="page": When you need to display documents with pagination, combine withpaginationUse tags, AnQiCMS will automatically handle pagination logic, there is no need to manually calculate page numbers.
  • Search keywords (q):When you need to display a list of documents containing specific keywords on the search results page, you can useq="搜索关键词"It is worth mentioning that when a user submits a keyword through the front-end search box, AnQiCMS will automatically capture the parameter in the URLqand it will take effect in thearchiveListtag to achieve seamless search.
  • Related documents (type="related"):On the document details page, you can usetype="related"To automatically retrieve other documents related to the current document, which helps to increase user stay time.
  • Custom field filtering (archiveFilters):In addition to the built-in properties, AnQiCMS also supports content filtering based on custom fields in the content model. This is usually associated witharchiveFiltersUsed in conjunction with labels, it is used to generate user-interactive filters on the front-end page (such as drop-down menus, checkboxes), allowing users to filter based on product properties such as color, size, etc.This provides the possibility for you to build a highly customized content filtering function.

A comprehensive example: displaying popular articles under a certain category with the 'recommended' attribute and supporting pagination.

”`twig {# Assuming the current page is a category list page, categoryId will be automatically retrieved #} {% archiveList popular_recommended_articles with type=“page” flag=“c” order=“views desc” limit=“10” %}

{% for item in popular_recommended_articles %}
    <div class="article-card">
        <img src="{{item.Thumb}}" alt="{{item.Title}}">
        <h3><a href="{{item.Link}}">{{item.Title}}</a></h3>
        <p>{{item.Description}}</p>
        <span>发布日期: {{stampToDate(item.CreatedTime, "2006-01-02")}}</span>
        <span>浏览量: {{item.Views}}</span>
    </div>
{% empty %}
    <p>当前分类下暂无推荐文章。</p>
{% endfor %}

{# 分页导航 #}
{% pagination pages with show="5"

Related articles

How to flexibly control and display the website navigation list (multi-level navigation) in the template?

In website operation, a clear and efficient navigation system is undoubtedly the foundation of user experience and search engine optimization.A well-designed navigation can not only guide users to quickly find the information they need, but also help search engines better understand the structure of the website.In AnQiCMS, we have powerful tools to flexibly configure and display multi-level navigation lists, thereby meeting diverse website needs. ### Step 1: Flexibly configure the navigation menu in the background AnQiCMS's navigation management feature is very intuitive.First, we will set up the core menu structure in the background "navigation settings"

2025-11-09

How to configure the TDK (title, keywords, description) of the homepage to enhance SEO display effect?

When we search for a keyword in a search engine, besides the sorting of search results, the first thing that catches our eye is the title, URL, and a brief description of each result.These are the three parts that we commonly refer to as website TDK - Title, Keywords, and Description.They are like your website's 'business card' on search engines, directly affecting whether users click to enter your website and how search engines understand your website's theme.The configuration of TDK is particularly crucial for the homepage of the website

2025-11-09

How to call and display contact information configured on the back-end in the website frontend?

It is crucial to clearly and conveniently display a company's contact information in modern website operations.AnQiCMS (AnQiCMS) understands this need and provides flexible and easy-to-operate backend configuration options, allowing you to dynamically display contact information on the website front end without writing complex code.This article will introduce in detail how to configure and call these contact methods in Anqi CMS, so that your users can find you first time. --- ### One, backend configuration contact information: Information Source All the data displayed on the front-end originates from the careful configuration of the backend.In Anqi CMS

2025-11-09

How does AnQiCMS's scheduled publishing feature ensure that content is displayed accurately online as planned?

Today, with the increasing refinement of content operation, how to ensure that carefully prepared content is presented to readers on time and as scheduled is a challenge facing many operators.In order to coordinate with market activities, maintain update frequency, or publish information across different global time zones, manual publishing always comes with inefficiency and potential human errors.The time publishing function of AnQiCMS (AnQiCMS) was born to solve this pain point, and it has become an indispensable and powerful assistant for content operation with its efficient and automated characteristics.The core of this feature lies in 'planfulness'

2025-11-09

How to precisely control the display of document title, introduction, content, and other elements on the article detail page?

The article detail page is the core display area of the website content, which directly affects the user's access experience and the perception of the website's professionalism.For AnQiCMS users, mastering how to finely control the display of various elements on the article detail page can not only enhance the visual appeal of the website but also optimize the user's reading path, effectively improving SEO performance.AnQiCMS as a flexible content management system provides various ways to help us accurately adjust the title, abstract, content, and other additional information presentation of the article detail page

2025-11-09

How does AnQiCMS handle images in document content (such as remote image download, Webp format conversion)?

## Mastering the Whole Picture: How AnQi CMS intelligently handles document content images, enhancing website loading speed and user experience In today's content-king digital age, the expressiveness, loading speed, and search engine friendliness of website images are crucial for user experience and SEO.A high-efficiency content management system should provide powerful and convenient functions in image processing.AnQiCMS (AnQiCMS) is well-versed in this field, helping users easily optimize website images through a series of intelligent image processing mechanisms. No matter where the images come from or in what format they exist, they will be properly handled

2025-11-09

How the generation and processing method of thumbnails (such as cropping, padding) affects the front-end image display?

Optimize website image display: In-depth analysis of Anqi CMS thumbnail processing method In content management, images are an indispensable element to attract users and convey information.Whether a website image is clear, beautiful, and loads quickly directly affects the user experience and the overall professionalism of the page.And the thumbnail as the first impression of the image display, its generation and processing method is particularly important.AnQiCMS (AnQiCMS) provides a flexible thumbnail generation and processing mechanism for image management, allowing us to finely control the display effect of front-end images according to the needs of different scenarios.### Thumbnail

2025-11-09

How to retrieve and display detailed information of a specified category (such as title, description, Banner image)?

In website operation, we often need to create unique and attractive display pages for specific categories, or flexibly call some detailed information of certain categories at different locations.For example, you may wish to display a dedicated Banner image at the top of a product category page, or list the title and introduction of a specific service category in the sidebar.AnQiCMS as an efficient and customizable content management system provides a very intuitive way to meet these needs.To obtain and display detailed information about a specified category, such as the title, description, and Banner image

2025-11-09