When using AnQi CMS for website content management, flexibly obtaining and displaying filter conditions is a key factor in improving user experience. Many friends are usingarchiveFiltersAt the interface, you may be curious whether it supports filtering conditions based on a specified category ID to provide more precise filtering options for different categories.Today, let's delve deeply into this issue.
By consulting AnQi CMS'sarchiveFiltersInterface document, we can clearly see the design intention and functional scope of the interface.archiveFiltersThe interface is mainly used to obtain the parameter filtering conditions of the document model. In its list of request parameters, we only found one namedmoduleIdThe field is required. This means that when you call this interface, you must provide a model ID, such as the article model (moduleId=1) or the product model (moduleId=2), and then it will return all the configured custom fields and their options under the model.
Therefore, the direct answer is:archiveFiltersThe interface does not support passing the category ID directlycategoryId) to get the filtering conditions for the category.The design approach is based on 'model' to define filtering fields, rather than 'category'.The logic behind this is that custom filter fields are usually bound to content models, for example, a "product" model may have "color", "size", "brand" and other filter fields, which are attributes that all products under the model (regardless of which subcategory they belong to) may have.
So, does this mean we cannot provide filtering functionality under a specific category? Of course not. Anqi CMS provides very flexible interface combination capabilities. AlthougharchiveFiltersIt does not directly support category ID, but we can achieve similar requirements by combining other interfaces.
Generally, you would first go througharchiveFiltersto get a certain interfacemoduleIdAll available filter options. These conditions, such as "city", "education", etc., are global options for this model.When a user enters a specific category page, such as the "Industry News" category under "News Dynamics", the filter displayed on the frontend is still based on the entire "article" model (i.e., moduleId).After the user selects specific conditions in these filters, you can usearchiveListThe interface to retrieve the document list that meets the conditions and belongs to the specific category.
archiveListThe interface is a powerful interface that supports passing in.categoryIdParameters to specify which category of documents to retrieve. It also supports passing througharchiveFiltersCustom filter parameters obtained. For example, you arearchiveFiltersGet the 'city' filter field, the user selected 'Beijing' in the 'Industry News' category. Then, when you callarchiveListyou can pass in at the same timecategoryId=行业新闻的IDandcity=北京So you can accurately obtain all documents about "Beijing" under the "Industry News" category.
In short,archiveFiltersWe provide all the filtering dimensions that a certain content model may have, andarchiveListIt is responsible for associating these filtering dimensions with specific classification content and for retrieval. When used together, they can build a user-friendly content display page that allows for filtering within categories.
Frequently Asked Questions (FAQ)
Q1: WhyarchiveFiltersThe interface does not providecategoryIdParameters to directly obtain the filtering conditions under the category?
A1:archiveFiltersThe interface design is based on the content "model" to define the filtering conditions.This means that filter fields (such as "color", "size") are usually attributes that all content under the model may have, rather than specifying a particular category.The Anqi CMS associates custom field configurations with models, ensuring the consistency and maintainability of filtering logic.
Q2: How to implement only displaying the available filtering conditions under a specific category in Anqi CMS?
A2: BecausearchiveFiltersThe interface returns all the filtering conditions under the model, you can process it on the front-end application level. First, you need to go throughmoduleIdRetrieve all filter conditions. Then, when the user visits a specific category, you can usearchiveListThe interface combines the category ID and filtering conditions to display content. If some filtering conditions do not have corresponding documents under this category,archiveListThe return result will naturally manifest. More refined control may require configuration of custom fields at the time of content publication to ensure that only relevant content is tagged with specific filtering labels.
Q3: How should I configure AnQi CMS if I need completely different filtering dimensions for different categories?
A3: If the filtering dimensions of different categories are so vastly different that they cannot share the same custom fields under a single model, you may need to consider creating different content models. Each content model can define a set of independent custom fields, which will becomearchiveFiltersThe interface returns the filtering conditions for the model. For example, if you have a “news” model and a “product” model, they will have their own sets of filtering conditions.