When building a website with AnQiCMS, we often have such questions: In addition to being able to accurately obtain detailed information of a specific document, does the system also provide a one-time retrieval function of all document lists under a certain category or model?The answer is affirmative.The auto CMS fully considers the flexibility of content management and display, and provides powerful interfaces to meet such needs.
To obtain the document list under a specific category or model, it mainly relies on the security CMS provided by the company./api/archive/listThis interface is the core tool for displaying your content list. It not only allows filtering by category and model, but also supports a wide range of query and sorting features.
Core Function Explanation: How to get the document list
/api/archive/listThe interface allows you to flexibly define the range of documents you want to retrieve. Here are some of its key parameters and usage:
Filter by model or category:
- Model ID (
moduleId):If you need to retrieve all documents under a specific model (such as the "articlemoduleIdEnglish translation: It is very useful for building lists of different types of content (such as product display pages, blog list pages). - ID (
categoryId)English translation: To get documents under a specific category, you can usecategoryId参数。Even better, it supports passingmultipleCategory ID, separated by commas, which means you can get the document content from multiple categories at once. For example, if you want to display articles from both the "News Updates" and "Industry Information" categories at the same time, you can do so bycategoryId="1,2"This way to implement.
- Model ID (
Containing subcategory documents (
child)Defaultly, when you specify a category ID, the interface usually includes all documents under its child categories. But if your requirement is to only getCurrent categoryThe document, excluding the content of its subcategories, can be setchild=falseto precisely controlPagination and quantity control (
page,limit): To better manage data volume and implement pagination loading,archive/listThe interface providespageandlimitParameter.- When
type="page"You can specifypageparameters to get the content of the nth page, and 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"Representing starting from the second item and fetching 10 items, which is very practical in some special data slicing scenarios.
- When
Sorting (
order): The order of content presentation is also important. You can useorderParameter 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. Supported fields includeid/views/category_id/created_time/updated_timeetc.Featured content filtering,
flag): Documents in the Auto CMS can be marked with different recommendation attributes (such as headline [h], recommended [c], slideshow [f], etc.). If you want to display documents with specific attributes only, you can useflagThe parameters are filtered. For example,flag="c"only documents marked as "Recommended" will be displayed.Keyword search (
q) and custom filtering: Intype="page"mode, you can alsoqPerform keyword search on parameters, matching content in document titles containing 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.gender, you can directly access throughgender=男How to filter out all documents with gender 'male'?
How to get the necessary ID?
In order to use/api/archive/listin the interfacemoduleIdandcategoryIdParameters, you may need to retrieve these IDs first. The Anqi CMS also provides the corresponding interface:
- Get category list: Through
/api/category/listThe interface allows you to get all categories or the category list under a specified model, so that you can find the one you needcategoryId. - Get model list: Through
/api/module/listInterface, you can get all the content models defined in the system, and then get the correspondingmoduleId. - Get document filtering conditionsIf you want to know which custom filter conditions a model supports, you can use
/api/archive/filtersthe interface, which will list the available filter fields and options for 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 a list of blog articles, product display pages, or a news center, or the implementation of complex filtering functions, these interfaces can provide solid support.
Common Questions (FAQ)
1. Can I get document lists under multiple categories at the same time?
Of course you can. In the call/api/archive/listthe interface,categoryIdThe parameter supports passing in a comma-separated string, for examplecategoryId="1,5,9"2. This allows you to retrieve all documents under these three categories at once.
2. How to query the filtering options for custom fields under a specific model?
If you are not sure what custom fields are available for filtering a content model, you can use/api/archive/filtersthe interface. Just pass the model'smoduleIdThe system will return all available filterable custom fields and their corresponding option lists, allowing you to construct accurate filter queries.
3. I want to get the latest 10 articles released, how should I set the parameters?
To get the latest 10 articles released, you can use/api/archive/listthe interface, and combineorderandlimitParameter. Specific settings can beorder="created_time desc"Sorted by publication time in reverse order, then setlimit="10"To limit the number of returned articles to 10.