When building a website with AnQiCMS, we often need to provide flexible filtering functions for different types of content so that visitors can quickly find the information they need according to their own needs.archiveFiltersThe interface is exactly for this, it can help us get the filtering conditions of the document. And in this interface,moduleIdthe parameter plays a crucial role.

archiveFiltersthe interface inmoduleIdDetailed explanation of the role of the parameter

When our website has a variety of content types, such as articles, products, service cases, etc., Anqi CMS will distinguish and manage these different types of content through 'models'.Each model can have its own unique fields, for example, the "product" model may contain fields such as "color", "size", "brand", etc., while the "article" model may only have "author", "publish date", etc.These custom fields are the basis for our content filtering.

archiveFiltersThe purpose of the interface is to return the list of all custom fields and their corresponding optional values under the model you specify. At this point,moduleIdThe parameters come into play.

To be specific,moduleIdThe parameter is used toSpecify the filtering conditions for the content model you want to retrieve. It is an integer representing a specific content model (such as,moduleId=1it could be the article model,moduleId=2Maybe it is a product model).

For example, suppose your website has a "Recruitment Information" module, which includes custom fields such as "City", "Education", and you associate this module with themoduleIdSet to 100. When you need to display these recruitment information filters on the front page, you can callarchiveFiltersthe interface and pass inmoduleId=100. The interface will base on thismoduleIdAccurately return the two filtering dimensions of "city" and "education level", as well as their respective options (such as city: Beijing, Shanghai; education level: Master, Bachelor, etc.).

If notmoduleIdThis parameter, the system will not know what type of content you want to get the filtering conditions for.Because different content models may have completely different custom fields and filtering logic, specify.moduleIdEnsured that the interface returns the filtering conditionsHighly relevant and accurateIt avoids incorrectly applying the 'product' filtering conditions to the 'article' content, thereby greatly improving user experience and data processing efficiency.

It's like a signpost, telling AnQi CMS: 'Please give me all the filter options for this specific content type.'This way, your website can dynamically display the most suitable filters for different categories or pages, making content organization and search more intelligent and convenient.For developers, this also means they can more easily build flexible and diverse frontend filtering interfaces without hardcoding a large amount of filtering logic.

Frequently Asked Questions (FAQ)

Q1: Where can I find a specific content model?moduleId? A1: moduleIdYou can view it on the content model management page of the AnQi CMS backend, usually each model will have a unique numeric ID. In addition, when callingarchiveListorarchiveDetailWhen the interface retrieves document or category information, the returned data will also includemodule_idfield, from which you can obtain the module ID of the corresponding document or category.

Q2: If I callarchiveFiltersNo interface providedmoduleIdHow will the parameters be? A2:As described in the API documentation,moduleIdIsarchiveFiltersinterface'sRequiredThis parameter indicates that if you do not provide this parameter, the interface will not respond normally, it will usually return an error message indicating that the necessary parameters are missing, or return an error code indicating that the request is invalid.This is to ensure that the system can accurately identify the content model you want to query.

Q3:archiveFiltersThe interface returns the filter conditions andarchiveListWhat is the relationship between the interface's custom filter parameters? A3: archiveFiltersThe interface returns exactlyarchiveListOptions for the "custom filter parameters" in the interface. In simple terms,archiveFilterstells you "which fields and options can be filtered", andarchiveListIt allows you to use these fields and options to 'actually filter out the document lists that meet the conditions'. For example,archiveFiltersIt might tell you that the "city" field has options like "Beijing", "Shanghai", and then you can add in thearchiveListrequest.city=北京Filter the documents in Beijing. They are a perfect match of building the frontend filter and executing the backend filtering logic.