How to ensure that only documents under the parent category are returned when retrieving the AnQiCMS document list, without including subcategories?

Calendar 👁️ 74

When using AnQi CMS to manage website content, we often encounter situations where we need to precisely control the display range of documents.For example, when you want to display only the documents directly published in a parent category page, without involving the content of its subcategories, you need to adjust the way the document list is obtained.AnQi CMS provides a very flexible API interface, allowing you to easily meet this requirement.

Ensure that the document list obtained only contains content under the parent category and automatically excludes all documents under subcategories, the key lies in cleverly utilizingarchiveListthe interface incategoryIdandchildthese two parameters.

First, you will use the Anqi CMSto get the document list interface, and its API call address is{域名地址}/api/archive/list. This is a powerful interface that allows you to filter and sort documents according to multiple conditions.

When you specify acategoryIdUnder normal circumstances, the Anqi CMS will be "smart" enough to return all documents under the category and all its subcategories.This is very convenient when building an aggregated page.However, if your design intention is to only display the direct content of the current category, this default behavior may not be very suitable.

at this point,childThe parameters come into play.childthe parameter is a boolean, which determines whether to include documents of all subcategories. Its default value istrueThis means it will include subcategories. When you need to limit the scope, only the current specifiedcategoryIddocument needs to be selected.childthe parameter tofalse.

For example, suppose your website has a parent category named "News Center," itscategoryIdWith100.Under the 'News Center', there may be subcategories such as 'Domestic News', 'International News', and so on.

GET {域名地址}/api/archive/list?categoryId=100&child=false

Through such a request, Anqi CMS will accurately filter out thosecategory_idExactly is100The document, while allparent_idWith100(i.e., the subcategory of 'News Center') documents will be cleverly excluded.

This fine control capability is of great significance for content operations.It allows you to present the most relevant and related content based on the specific functions of the page and the user's browsing habits.child=true(or omittedchildParameters to fully present all relevant content. This flexibility ensures the clarity of the website's content structure and the optimization of user experience.

Frequently Asked Questions (FAQ)

Q1: How can I display the documents of a specified category and all its subcategories?A1: If you want to get all documents under a specified category, including documents in its subcategories, you can omitchildthe parameter, or explicitly set it tochild=truebecausetrueIschildThe default behavior of parameters. For example:GET {域名地址}/api/archive/list?categoryId=100It can achieve this effect.

Q2: Can I get documents from multiple parent categories at the same time, and also exclude the subcategories of these parent categories?A2: OK.categoryIdThe parameter supports passing multiple category IDs separated by commas. So, you can construct the request like this:GET {域名地址}/api/archive/list?categoryId=100,101,102&child=falseThis will return.categoryIdWith100/101or102The direct document, which will not include any documents in the subcategories of these categories.

Q3: Thischild=falseParameter whether it also applies to retrieving the document list by model ID (moduleId)?A3: Yes,child=falseThe parameter mainly relates tocategoryIdCombine them to control the document inclusion relationship of a specific category level.moduleIdUsed to filter all documents under a specific document model (such as articles, products, etc.). You can first go throughmoduleIdSpecify the document model and then proceed throughcategoryIdandchild=falseFurther refine the filtering results. For example:GET {域名地址}/api/archive/list?moduleId=1&categoryId=100&child=falseRetrieve the document under the article model and directly belongs to the category ID 100.

Related articles

What is the role of `url_token` in the AnQiCMS document list results, and how is it used to generate friendly URLs?

In AnQiCMS, `url_token` is a crucial concept, it is not only a field in the document list, but also the core element for building friendly URLs (Friendly URL) of the website.Understanding its role and usage can help us better optimize the website structure, improve user experience, and search engine rankings.

2025-11-09

How to efficiently extract and display the article summary (description field) from the AnQiCMS document list?

It is crucial to provide clear and attractive summaries for articles on the website in content management.This not only helps search engines better understand the page content and improve inclusion and ranking, but also quickly captures the attention of visitors on list pages, search results pages, or social sharing, guiding them to click and read the full content.AnQiCMS (AnQiCMS) provides a variety of flexible ways to manage and retrieve this content, and efficiently extracting and displaying the article summary (`description` field`) is a common need in our daily operation. AnQiCMS

2025-11-09

When `archive/list` returns `code` as `-1`, what error messages will the `msg` field provide?

When using Anqi CMS for website content management, we often deal with various API interfaces, among which the `archive/list` interface is the core for obtaining the document list.You may encounter the situation where the interface returns `code` as `-1` during use.At this moment, understanding the information provided by the `msg` field is particularly important, as it helps us quickly locate the source of the problem.

2025-11-09

How to combine the filtering conditions obtained from `archiveFilters.md` and apply them to the custom filtering parameters of `archive/list`?

In Anqi CMS, efficiently managing and displaying website content is the key to improving user experience.When the amount of content grows, providing flexible filtering functions is particularly important to help visitors quickly find the information they need.The AQ CMS provides powerful API interface support, by cleverly combining the filtering conditions obtained from the `archive/filters` interface and applying them to the custom filtering parameters of the `archive/list` interface, we can build extremely practical content filtering functionality.###

2025-11-09

I want to display the number of comments for each article on the AnQiCMS document list page, which field should I check?

In the daily use of AnQiCMS, many operators hope to be able to directly display the number of comments for each article on the article list page.This not only effectively enhances the activity of the content, but also helps users quickly understand which articles are more popular and have more discussion value.Then, among all the data fields, which one should we focus on in order to meet this requirement?

2025-11-09

What is the significance of the `price` and `stock` fields returned by the `archive/list` interface for e-commerce document models?

In AnQi CMS, when you retrieve the document list through the `archive/list` interface, the returned data includes the `price` and `stock` fields, which are of vital importance for constructing an e-commerce website model.They are not just simple numbers, but are the core elements supporting product display, transaction process, and inventory management.

2025-11-09

How to get the articles published by a specified user (`user_id`) through the AnQiCMS document list?

In website content operation, we often need to display all articles of a specific author, such as on the author's personal homepage, or on a special topic page aggregating the content of specific contributors.AnQiCMS (AnQiCMS) provides a powerful and flexible API interface, allowing us to easily meet this requirement. To get the list of all articles published by a specified user (`user_id`), we need to use the `archive/list` interface.

2025-11-09

What is the default behavior and return content of the `archive/list` interface when no parameters are passed?

## In-depth Analysis of AnQiCMS `archive/list` Interface: Default Behavior and Return Content when No Parameters Are Provided When developing or managing websites with AnQiCMS, we often need to obtain various data through API interfaces.The `archive/list` interface is one of the core interfaces for obtaining the document list of the website.Understanding its default behavior and return content when no parameters are passed is crucial for efficient data acquisition and initial debugging.

2025-11-09