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

Calendar 👁️ 76

How to accurately filter articles under specific categories in Anqi CMS, which is a key aspect for improving the organization of website content and user experience.Anqi CMS provides a powerful and flexible interface, 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 the specific category articles you hope to see.

Master the document list interface: the core of content filtering

To filter articles under specific categories, we need to make use of the Anqi CMS provided/api/archive/listThe interface. This interface is the core for obtaining the list of website documents, allowing you to precisely control the set of returned articles through various parameters.

The method of calling the interface isGETThis means you can pass filtering conditions through URL parameters. Where,categoryIdParameters are the key to implementing category-based article filtering.

UnderstandingcategoryIdParameter

categoryIdThe parameter allows you to specify one or more category IDs, and the interface will return articles belonging to these categories.

  • Single category filteringIf you only want to display articles under a specific category, you can directly pass the category ID. For example, if you want to get the ID of10articles under the category, the request parameters can includecategoryId=10.
  • multi-category filtering: If you want to display articles under multiple categories at the same time,categoryIdthe parameter also supports commas,Pass multiple category IDs in the form of separation. For example, to get the ID of10/12and15articles under the category, you can setcategoryId=10,12,15.

build your filter request

exceptcategoryIdIn practice, it is usually necessary to combine other parameters to construct a complete request to ensure that you get the content you really need.

  • moduleId(Model ID): Documents usually belong to a specific model (such as article model, product model, etc.). To filter more accurately, it is recommended that you also specifymoduleIdFor example,moduleId=1means to retrieve documents under the article model.
  • type(List type): When you need to get a paginated list and display the total count, it is usually thattypeis set topage. If you just want to list a specified number of documents,typeyou can omit or set it tolist.
  • child(Subcategory includes): A category may contain multiple subcategories. If you want to display not only the articles of the current category but also the articles of all its subcategories, you can setchildthe parameter totrue. By default, Anqi CMS usually includes subcategories, but it can be specified explicitlychild=falseYou can only get the articles directly under the current category, without including the content of its subcategories.
  • limitandpage(Pagination control): To control the number of articles displayed per page and to retrieve content for specific page numbers, you can uselimitandpagethe parameters. For example,limit=10&page=1to get the first 10 articles of the page.

a complete request examplemight look something like this:

{域名地址}/api/archive/list?moduleId=1&categoryId=10,12,15&type=page&limit=10&page=1&child=true

The meaning of this request is: to get the article modelmoduleId=1under, the category ID is10/12and15(including subcategories) articles displayed in a paginated manner, 10 per page, to get the content of the first page.

Parse the return result

After you send the request, AnQi CMS will return a JSON formatted response. A successful response will usually includecode: 0and adatafields, among whichdataA field is an array containing articles that meet the filtering criteria. Each article object will containid/title/description/category_idetc. information, you can display this information on the front end.

Check the returned data to verifycategory_idthe field, you can verify if the interface has been filtered according to your expectations. In addition, iftypethe parameter topage, the response will also include atotalField, tells you the total number of documents that meet the criteria, which is very helpful for implementing pagination.

Summary

By flexible applicationarchive/listThe interface and itscategoryIdParameters, you can accurately control the display of content on the AnQi CMS website.This interface can provide solid support for building category lists, special topic pages, and even more complex filtering functions. CombinedmoduleId/typeandchildWith parameters, you can create a feature-rich and user-friendly content display page.


Frequently Asked Questions (FAQ)

1. How to get the categories ofcategoryId?

You can call/api/category/listInterface to get the list of all categories, where each category will containidfields, this is what you needcategoryId. You can also get/api/category/detailinterface, passing the category name (catnameorfilenameTo get the details of a single category, which also includesid.

2. How can I display articles under a category without including articles from subcategories?

When calling/api/archive/listparameter to:childthe parameter tofalse.categoryId=10&child=false. The API will only return articles directly belonging to the ID of10category, and will not include articles from its subcategories.

3. How can I exclude certain categories of articles instead of just displaying specific categories of articles?

Of Security CMS/api/archive/listThe interface also provides aexcludeCategoryIdParameter. You can pass the category IDs to be excluded in comma-separated format,to this parameter. For example,excludeCategoryId=10,12It will return all articles but exclude those belonging to category10and12ID articles.

Related articles

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 latest document list of the specified model (`moduleId`) through AnQiCMS?

In website content management, we often need to dynamically display the latest updates of a certain type of content, such as news articles, product releases, or blog updates.For websites built using AnQiCMS, leveraging its powerful API interface to obtain the latest document list under a specified model is a very basic and practical operation.This can not only help developers build dynamic pages quickly, but also provide users with timely updated information, optimizing the user experience of the website.To implement this feature, we mainly use the AnQiCMS provided

2025-11-09

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

In website operation, we often need to flexibly display content, such as displaying the latest articles on a page, but not including content under certain specific categories, such as announcements or internal news.AnQiCMS as a powerful content management system, provides a rich set of API interfaces to meet these complex display requirements.Today, let's delve into a very practical parameter of the `archive/list` interface: `excludeCategoryId`, especially how it supports excluding multiple categories of documents.###

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