What would the `archiveFilters` interface return if a document model does not have filterable custom fields?

Calendar 👁️ 74

In AnQi CMS,archiveFiltersAn interface is a very practical feature that allows us to obtain the filtering conditions of a specific document model, thereby helping users to implement flexible content filtering on the front-end page.For example, on a product display page, we may need to filter based on the product's attributes such as 'color', 'size', or 'brand'.

So, if a document model is exactly not configured with any selectable custom fields, the call toarchiveFiltersWhat will the interface return? The answer is actually very simple: it will return a successful response, but the data part ("datawill be an empty array[].

This conforms to the good practice of most API designs. When the requested dataset does not exist or is empty, the API usually does not return an error status code (such as-1),unless the request parameters themselves are incorrect (such asmoduleIddoes not exist). Instead, it will return a representation of success(code: 0But the data structure of the empty result set.This means that in AnQi CMS, the system explicitly informs you that you have successfully queried the filtering conditions under the model, but there are currently no filtering fields that meet the conditions.

This is crucial for frontend developers to understand. When you callarchiveFiltersWhen interfacing, proper handling is requireddataBe prepared for the field to be an empty array. You can checkdataThe length of the array is zero to determine whether the current model provides a filtering function.If empty, the corresponding filtering area on the front-end interface does not need to be rendered, or it can display a friendly prompt, such as 'No filtering conditions available'.This can avoid program errors caused by attempting to iterate over a non-existent or undefined filter list, and also optimize the user experience.

If you want to add a filtering feature to a document model, so that it can bearchiveFiltersThe interface returns meaningful data, you need to configure the document model in the Anqi CMS backend.The specific steps usually involve entering "Document Model ManagementarchiveFiltersIt can only be returned by the interface. Once set and saved, the data of these fields will bearchiveFiltersThe interface identifies and returns, including the screening name, field calling name, and the specific screening parameter list (such as Beijing, Shanghai, etc.).

In short,archiveFiltersThe interface returns an empty array when there are no filterable custom fields.[]This is a normal response behavior, developers should handle it according todatawhether the array is empty to flexibly display or hide the filtering function.


Frequently Asked Questions (FAQ)

Q1:archiveFiltersThe interface returns an empty array[]Is it an error?A1: No.This indicates that the interface call was successful, but the current document model does not have any custom fields configured for filtering.dataThe array is empty.

Q2: How do I know if a document model is configured with filterable custom fields?A2: The most direct method is to callarchiveFiltersthe interface and check the returned data.dataarray. ifdataThe array is not empty, which means the model contains filterable fields.You can also check the custom field settings of the specific model in the "Document Model Management

Q3: If I need a filter function, how can I makearchiveFiltersthe interface return data?A3: You need to log in to the AnQi CMS backend, find the corresponding document model, and enter the custom field management page.In there, enable the 'filterable' option for custom fields that you want to use as filter conditions (for example, text, radio, checkbox field types).archiveFiltersThe interface will return these configured filter conditions.

Related articles

Does the `archiveFilters` interface support retrieving filtering conditions based on a specified category ID?

When using Anqi CMS for website content management, flexibly obtaining and displaying filter conditions is a key link in improving user experience.Many friends may wonder when using the `archiveFilters` interface whether it supports retrieving filtering conditions based on specified category IDs to provide more accurate filtering options for different categories.Today, let's delve deeply into this issue.

2025-11-09

In what scenario should `archiveFilters` be used instead of `archiveParams`?

During the development and content management of Anqi CMS, we often need to obtain relevant information about documents (Archive).Among them, `archiveFilters` and `archiveParams` are two API interfaces closely related to custom fields, but their design purposes and application scenarios are different.Understanding the difference between them can help us build website features more efficiently and enhance the user experience.First, let's briefly understand the core functions of these two interfaces.

2025-11-09

What is the difference between the interface for getting document parameters (`archiveParams`) and the interface for getting document parameter filtering conditions (`archiveFilters`)?

When using AnQiCMS for website content management, we often need to deal with document-related API interfaces.Among them, the interface names `archiveParams` and `archiveFilters` sound similar at first glance, and they are both related to Understanding the differences between them can help us develop and manage websites more efficiently.

2025-11-09

How to configure custom fields in Anqi CMS so that they can be used as filter conditions?

In AnQi CMS, configuring custom fields as filter conditions is a very practical feature to make your website content more dynamic and interactive.It can help users quickly find the content they need based on specific attributes, thereby significantly improving the user experience of the website.Next, let's learn how to implement this feature in AnQi CMS. ### Custom Field: The "Alive" Tag of Content Firstly, we need to understand what a custom field is.

2025-11-09

How to properly handle the error codes returned by the `archiveFilters` interface (such as -1, 1001, 1002)?

During the operation and development of the website, we often use various API interfaces provided by Anqi CMS to dynamically obtain and display content.Among them, the `archiveFilters` interface plays an important role, helping us to obtain the document filtering conditions, thus providing users with a more refined content browsing experience.However, correctly handling the error codes returned by any API is crucial to ensure the stable operation of the website and a smooth user experience.

2025-11-09

Does the `archiveFilters` interface require user login authorization to access?

In the daily application of Anqi CMS, the `archiveFilters` interface is an important tool for dynamically displaying filter conditions on the front-end page. It allows the website to generate various filter options based on the field configuration of the article model, such as "city", "education", and so on.It is crucial for building a user-friendly content browsing experience, where users can quickly locate content of interest through these filtering conditions.However, many developers may have a question when integrating: does this interface require user login authorization to access?To answer this question

2025-11-09

How to dynamically build a frontend filtering UI based on the response of `archiveFilters`, such as dropdown menus or checkboxes?

In today's increasingly rich content of websites, how to allow users to quickly find the information they are interested in is a crucial operational issue.AnQiCMS provides powerful content management capabilities, and its API interface provides a solid foundation for front-end developers to build flexible and varied interactive interfaces.Today, let's delve into how to use the response data from the `archiveFilters` interface to dynamically build front-end filtering UI, such as common dropdown menus or checkboxes.The value of dynamic filtering interface Imagine that

2025-11-09

How to get the latest document list of the specified model (`moduleId`) through AnQiCMS?

In website content management, we often need to dynamically display the latest updates of a certain type of content, such as news articles, product releases, or blog updates.For websites built using AnQiCMS, leveraging its powerful API interface to obtain the latest document list under a specified model is a very basic and practical operation.This can not only help developers build dynamic pages quickly, but also provide users with timely updated information, optimizing the user experience of the website.To implement this feature, we mainly use the AnQiCMS provided

2025-11-09