Does the AnQiCMS document list interface support excluding multiple categories of documents at the same time (`excludeCategoryId` usage)?

Calendar 👁️ 69

In website operation, we often need to display content flexibly, such as displaying the latest articles on a page, but not including content from certain specific categories, such as announcements or internal news.AnQiCMS as a powerful content management system, provides a wealth of API interfaces to meet these complex display requirements.Today, let's delve intoarchive/listAn extremely practical parameter in the interface:excludeCategoryIdEspecially how it supports excluding multiple categories of documents simultaneously.

excludeCategoryIdThe magic of the parameter: precisely excluding multi-category documents.

When you usearchive/listThe interface to get the document list isexcludeCategoryIdParameters play an important role in content filtering. Its original intention is to allow you to precisely control which categories of documents are not displayed in the results.According to the official documentation of AnQiCMS, this parameter is defined asstringType, and its key feature lies in:Multiple category IDs can be separated by English commas,with.

This means, if you want to exclude all documents with category ID of5/8and12just setexcludeCategoryIdThe parameter value is set to5,8,12It is done. After receiving this parameter, the system will intelligently filter out all content under these three categories in the returned results, thereby greatly simplifying the fine-grained management and display logic of the content.

For example, if you want to get all documents with model ID 1 but do not want to include content with category ID 5 and 8, your API request can be constructed as follows:

GET {域名地址}/api/archive/list?moduleId=1&type=page&excludeCategoryId=5,8

In this way, you can easily obtain a list of documents excluding a specific category.

Why is this feature so practical?

This feature has a very wide range of application scenarios in the actual website content operation, and can help us organize and display content more efficiently:

  • Personalized content displayIn the "Latest News" or "Recommended Content" module on the homepage, you may want to display all the latest articles, but need to exclude specific categories such as "Company Announcements" or "Marketing Activities" to maintain the professionalism and focus of the homepage content.
  • Optimize related recommendations: Usually, under the article detail page, modules such as "related articles" or "you might also like" will be displayed. UsingexcludeCategoryIdYou can exclude the category of the current article (to avoid self-promotion) or exclude some outdated, inactive categories to ensure the quality and user experience of the recommended content.
  • Content management and testingIn A/B testing, it may be necessary to display different content sets to different user groups, which may involve excluding certain specific categories of content. In some special content management scenarios, it is necessary to temporarily hide the content of a certain category without deleting or modifying the category itself,excludeCategoryIdCan be put to use.
  • Simplify front-end logic: Front-end developers do not need to filter all data after obtaining it, they can directly complete preliminary filtering through API parameters, which reduces the amount of data transmission and the complexity of front-end processing, and improves the page loading efficiency.

Implementation suggestions and precautions

While usingexcludeCategoryIdWhen setting parameters, there are some details to note to ensure that they function correctly and effectively:

  1. Parameter type and format: Always setexcludeCategoryIdThe value is considered a string, even if only one category is excluded, it is recommended to be written asexcludeCategoryId=5instead ofexcludeCategoryId=5ID's must be separated by English commas.,Separate with commas, avoid spaces or other non-numeric characters, which may cause parsing errors.
  2. CombinecategoryIdUse:excludeCategoryIdCan be used withcategoryIdParameters can be used at the same time. For example, you can specifycategoryId=1,2,3To explicitly include documents of these three categories, and to pass throughexcludeCategoryId=2To exclude documents from these three categories with category ID 2. This provides great flexibility for building complex filtering logic.
  3. NotechildParameter: AnQiCMS'archive/listThere is also anotherchildparameter, the default istrueindicating that in the querycategoryIdit will automatically include the documents of its subcategories. If yourexcludeCategoryIdIt includes the ID of a parent category, which will only exclude the parent category itself and will not automatically exclude all its subcategories unless the IDs of these subcategories are also explicitly listed.excludeCategoryIdIn. If you only want to exclude a specific category without affecting its parent or child categories, please consider it carefully.categoryIdandchildthe combination of parameters.
  4. First, get the category ID: In actual development, it is recommended to go through first.category/listThe interface retrieves the required category ID and dynamically constructsexcludeCategoryIdparameters to avoid hardcoding and potential errors.

In short, AnQiCMS'sarchive/listprovided by the interfaceexcludeCategoryIdThe parameter is a powerful and flexible tool that allows website operators and developers to control the display of document lists in unprecedented ways, achieving smarter and more user-friendly content presentation.Mastering this usage will effectively enhance the content operation efficiency and user experience of your website.


Frequently Asked Questions (FAQ)

Q1:excludeCategoryIdCan it be used withcategoryIdat the same time?

A1:Yes,excludeCategoryIdandcategoryIdThese two parameters can be used simultaneously to achieve more fine-grained filtering control. For example, if you specifycategoryId=10,11,12to retrieve documents under these three categories, and at the same time setexcludeCategoryId=11In the end, the document will only contain the content of categories 10 and 12, and the documents of category 11 will be excluded.

Q2: I want to exclude all child categories under a certain parent category, is it valid to only specify the parent category's ID inexcludeCategoryId?

A2: excludeCategoryIdIt is to exclude the specified category ID explicitly. Ifarchive/listinterface'schildParameters (default totrue)is effective,categoryIdIt will include its subcategories. Therefore, if you want to exclude a parent category and all its subcategories, the safest way is to get all the subcategory IDs under the parent category and then include these IDs along with the parent category ID.excludeCategoryIdParameters should be separated by commas.

Q3:excludeCategoryIdDoes the parameter affect performance? How many category IDs can I exclude?

A3:Any filtering parameter will have an impact on the database query.excludeCategoryIdAlso, in most cases, excluding a small or moderate number of category IDs will not cause significant performance issues. The AnQiCMS documentation does not explicitly state this.excludeCategoryIdThe maximum number of acceptable category ID. However, in actual use, if a large number of category IDs need to be excluded, it may have an impact on query efficiency.In such extreme cases, it may be necessary to consider optimizing the classification structure or adjusting the content display logic.It is recommended to conduct sufficient testing before deploying to the production environment.

Related articles

How to filter the AnQiCMS document list to display articles under a specific category (`categoryId`)?

How to accurately filter out articles under specific categories when managing and displaying a large amount of content in Anqi CMS is a key link to improve the organization of website content and user experience.Strong and flexible interfaces are provided by AnQi CMS, allowing us to easily achieve this goal.This article will provide a detailed introduction on how to use the document list interface of Anqi CMS to only display specific categorized articles that you hope to see.### Master the document list interface: the core of content filtering To filter articles under specific categories, we need to use the `/api/archive/list` interface provided by AnQi CMS

2025-11-09

How to implement descending order by publish time, view count, or update time in the AnQiCMS document list?

In website operation, how to efficiently present content lists so that users can quickly find the information they are most interested in or most valuable is an important issue.AnQiCMS provides a flexible document list feature, allowing us to easily implement content list sorting in descending order based on multiple conditions, such as publication time, page views, or update time.This not only optimizes the user experience, but also helps to improve the visibility and interaction of the content.

2025-11-09

How to precisely control the number of documents returned and the starting offset of AnQiCMS document list (advanced usage of `limit` parameter)?

When building and managing website content, AnQiCMS provides a series of flexible API interfaces to help us accurately obtain and display data.Among them, the `archive/list` interface is the core for obtaining the document list, and its `limit` parameter demonstrates its powerful fine-grained control capabilities in terms of controlling the number of returned items and the starting offset.Understand and master the advanced usage of the `limit` parameter, which can make our website content display more flexible and efficient.### `limit` parameter basic usage

2025-11-09

What is the main difference between the `type="page"` and `type="list"` modes in the AnQiCMS document list interface?

When you are using AnQiCMS to build a website and need to retrieve document content from the backend, you will often encounter the document list interface (/api/archive/list).This interface provides a very important `type` parameter, which determines how you will obtain and process the document list data.A deep understanding of the core differences between the `type="page"` and `type="list"` modes is crucial for improving website performance, optimizing user experience, and developing more flexible features.###

2025-11-09

How to get the document list with 'Headline' or 'Slide' recommended attributes (`flag`) in AnQiCMS?

In AnQiCMS (AnQiCMS), content managers often need to flexibly display important content on the website, such as setting specific articles as 'headline' or 'slideshow' to attract users' attention.The AnQi CMS provides a very practical feature, that is, marking documents through the 'recommended attribute' (flag).If you want to get the list of documents marked specially, the AnQiCMS API interface can help you achieve it easily.

2025-11-09

How does the `child=false` parameter affect the display of categories and their subcategories when retrieving the document list?

In Anqi CMS, the `archive/list` interface is the core tool for obtaining the list of website documents, which provides a variety of parameters to help us accurately filter and display content.Among them, the `child` parameter, although simple in appearance, plays a vital role in the display of categories and their subcategories in documents, directly affecting the granularity of content presentation.Understand and make good use of this parameter, it can make the content organization of your website clearer and improve the user experience.By default, when you access `archive/list`

2025-11-09

How to use the `q` parameter to perform keyword search in the AnQiCMS document list and realize the in-site search function?

In the daily operation of a website, providing users with an efficient and convenient in-site search function is a key factor in improving user experience and guiding content discovery.For those of us using AnQiCMS to manage website content, it is not difficult to achieve this function.AnQi CMS provides a very practical parameter——`q`, which allows us to easily search for keywords in the document list.### Start the in-site search journey: Understanding the `q` parameter In the AnQiCMS document list interface (/api/archive/list), `q`

2025-11-09

How to handle the `extra` field returned by the `archive/list` interface to obtain custom field information?

When using AnQi CMS for website content management, we often need to display more personalized data beyond the usual information such as title, summary, thumbnail, etc.This additional information, such as the author of the article, the model of the product, the release location, etc., is achieved through the powerful custom field function of Anqi CMS.How can we elegantly extract and utilize these custom fields when we obtain the document list through the `archive/list` interface on the front end?The answer is hidden in the `extra` field of the returned data

2025-11-09