When building a website with AnQiCMS, we often have such questions: In addition to being able to accurately obtain the detailed information of a specific document, does the system also provide the function of obtaining a list of all documents under a certain category or model at one time?The answer is affirmative. Anqi CMS fully considers the flexibility of content management and display, providing powerful interfaces to meet such needs.

To get the document list under a specific category or model, it mainly relies on the Anqi CMS provided/api/archive/listThe interface is the core tool for displaying your content list. It not only allows you to filter by category and model, but also supports rich query and sorting functions.

Core feature explanation: How to get the list of documents

/api/archive/listThe interface allows you to flexibly define the range of documents you want to retrieve. Here are some key parameters and usage:

  1. Filter by model or category:

    • Model ID(moduleId)If you need to retrieve all documents under a specific model (such as the "article" model, "product" model), just pass the correspondingmoduleIdIt is. This is very useful for building different types of content lists (such as product display pages, blog list pages).
    • Category ID (categoryId): To get documents under a specific category, you can usecategoryIdParameter. What's more, it supports passing inmultipleCategory ID, separated by commas, which means you can retrieve document content from multiple categories at once. For example, if you want to display articles from both "News Updates" and "Industry Information" categories, you can do so bycategoryId="1,2"This way to implement.
  2. Containing sub-category documents(child): By default, when you specify a category ID, the interface usually includes all documents under its child categories. But if your requirement is to only getthe current categorythe document, excluding the content of its subcategories, can be controlled by settingchild=falseto precisely control.

  3. Pagination and quantity control (page,limit): In order to better manage data volume and implement pagination loading,archive/listThe interface providespageandlimitParameter.

    • Whentype="page"When you specifypageparameters to retrieve the content of the page number, the system will also return the total number of documents (total), which is crucial for building pagination navigation.
    • limitThe parameter is used to control the number of documents returned per page or per request. It even supports offset mode, for examplelimit="2,10"Represents starting from the second item and fetching 10 items, which is very practical in some special data slicing scenarios.
  4. Sorting (order): The order of content presentation is also important. You can useorderThe parameter specifies the sorting method, for exampleorder="created_time desc"You can get the latest documents,order="views desc"Then you can sort by views from high to low. The supported fields includeid/views/category_id/created_time/updated_timeetc.

  5. Featured content filtering(flag): Documents in AnQi CMS can be marked with different recommendation attributes (such as headline [h], recommended [c], slideshow [f], etc.). If you want to display only documents with specific attributes, you can useflagFilter parameters. For example,flag="c"Only documents marked as "Recommended" will be displayed.

  6. Keyword search (q) and custom filtering: Intype="page"mode, you can also useqThe parameter performs keyword search, matching content in the document title that contains specific words.In addition, if you have set filterable custom fields in your document model, these fields can also be used as query parameters to achieve more refined content filtering.For example, if there is a custom fieldgenderYou can directly go throughgender=男to filter out all documents with male gender.

How to get the necessary ID?

In order to use/api/archive/listthe interface inmoduleIdandcategoryIdParameters, you may need to obtain these IDs first. Anqi CMS also provides the corresponding interface:

  • Get category list: Pass/api/category/listInterface, you can get the list of all categories or the list of categories under the specified model, so that you can find what you needcategoryId.
  • Get model list: Pass/api/module/listInterface, you can get all the content models defined in the system and get the correspondingmoduleId.
  • Get document filtering conditions: If you want to know which custom filter conditions a model supports, you can use/api/archive/filtersan interface that lists the available filter fields and options of the specified model.

In summary, Anqi CMS provides a comprehensive API that allows you not only to obtain detailed content of individual documents but also to organize and display document lists in an extremely flexible and powerful way, based on categories, models, recommended attributes, keywords, even custom fields.Whether it is building a blog article list, product display page, news center, or implementing complex filtering functions, these interfaces can provide solid support.


Frequently Asked Questions (FAQ)

1. Can I get the document list under multiple categories at the same time?

Of course you can. When calling/api/archive/listthe interface,categoryIdThe parameter supports passing in a comma-separated string, for examplecategoryId="1,5,9"So you can get all documents under these three categories at once.

2. How to query the filtering options of custom fields under a certain model?

If you are unsure about which custom fields are available for filtering in a content model, you can use/api/archive/filtersthe interface. Just pass the model'smoduleIdThe system will return all the selectable custom fields and their corresponding option lists, allowing you to build an accurate filter query.

3. How do I set the parameters to get the 10 latest published articles?

To get the 10 latest published articles, you can use/api/archive/listthe API and combine withorderandlimitParameters. The specific settings can beorder="created_time desc"then set by sorting by publication time in reverse orderlimit="10"to limit the number of returned articles to 10.