When using Anqi CMS for website content management, flexibly obtaining and displaying filter conditions is a key factor in enhancing user experience. Many friends have been usingarchiveFiltersAt interface time, you may wonder if it supports retrieving filtering conditions based on a specified category ID, so as to provide more accurate filtering options for different categories.Today, let's delve into this issue in depth.
By referring to thearchiveFiltersInterface documentation, we can clearly see the original 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 request parameter list, 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 product model (moduleId=2), and it will return all the configured, customizable fields and options available for filtering under that model.
Therefore, the direct answer is:archiveFiltersThe interface does not support passing the category ID directlycategoryId)To get the filtering conditions for the category.Its design concept is based on "modelThe logic behind this is that custom filter fields are usually bound to content models, for example, a "product" model may have filter fields such as "color
So, does this mean we cannot provide a filtering function under a specific category? Of course not. Anqi CMS provides very flexible interface combination capabilities. AlthougharchiveFiltersIt does not directly support classification ID, but we can achieve similar requirements by combining other interfaces.
Generally, you would first go througharchiveFiltersto get a certain interfacemoduleIdAll available filtering conditions.These conditions, such as "cityWhen the user enters a specific category page, such as the 'Industry News' category under 'News Dynamics', the filter you display on the frontend is still based on the entire 'Article' model (i.e., moduleId).archiveListThe interface is used to obtain a list of documents that meet the conditions and belong to the specific category.
archiveListThe interface is a powerful interface that supports passing incategoryIdParameters can be used to specify which category of documents to retrieve. It also supports passing through parameters.archiveFiltersCustom filter parameters obtained. For example, you can inarchiveFiltersObtained the 'City' filter field, the user selected 'Beijing' in the 'Industry News' category. Then, you can pass inarchiveListat the same time.categoryId=行业新闻的IDandcity=北京This allows for precise retrieval of all documents about 'Beijing' under the 'Industry News' category.
In short,archiveFiltersWe provide all possible filtering dimensions that a content model may have.archiveListThen it is responsible for associating and retrieving these filtered dimensions with specific category content. When used together, they can build a user-friendly content display page with filterable categories inside.
Common Questions (FAQ)
Q1: WhyarchiveFiltersInterface did not providecategoryIdParameters to directly obtain the filtering conditions under the category?
A1:archiveFiltersThe design of the interface is based on the content 'model' to define filtering conditions.This means that filter fields (such as 'Color', 'Size') are usually attributes that all content under the model may have, and do not specifically refer to a category.The Qiyu CMS associates the configuration of custom fields with the model, ensuring the consistency and maintainability of the filtering logic.
Q2: How to implement only displaying available filtering conditions under a specific category in the AanQi CMS?
A2: Due toarchiveFiltersThe interface returns all the filtering conditions under the model, you can process them on the frontend application level. First, you need to go throughmoduleIdRetrieving all filter conditions. Then, when a user visits a specific category, you can usearchiveListThe interface combines the category ID and filter conditions to display content. If some filter conditions do not have corresponding documents in this category,archiveListThe returned result will naturally reflect.A finer control may require configuring custom fields at the time of content publishing 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 there is a significant difference in the filtering dimensions of different categories, to the extent that they cannot share the same model's custom fields, you may need to consider creating different content models for this content. 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 each have their own set of filtering conditions.