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

Calendar 👁️ 69

During the development and content management of Anqi CMS, we often need to obtain relevant information about documents (Archive). Among them,archiveFiltersandarchiveParamsThese are two API interfaces closely related to custom fields, but they have different design purposes and application scenarios.Understanding the difference can help us build website features more efficiently and improve user experience.

Let's take a simple look at the core functions of these two interfaces.

archiveParamsThe interface (get document parameters) is mainly used to retrieve the definitions of all custom fields of a document model, or the custom field values filled in by a specific document instance.When we request this interface, it will return a list containing field names, field names (field_name), types, default values, and even the optional values of a field (for example, if it is a multi-select field, it will return a string separated by newline characters).Its main purpose is to let developers understand the structure of the document model or to display the complete attribute information of a single document on the front end.For example, on a product detail page, you may need to display all custom attributes of the product such as "size", "color", "material", and their corresponding values, at this timearchiveParamsIt's very suitable.

AndarchiveFiltersThe interface (to get the document parameter filtering conditions) is an interface focused on the 'filtering' function.Its original design was to facilitate the construction of dynamic filters on the front-end page.When we callarchiveFiltersWhen a model ID is passed, it returns all custom fields marked as 'filterable' under the model, each with an attacheditemsThis array.itemsThe array includes all possible options (label) for the filtering field, and more importantly, it may also include the document count (total) for each option. Imagine, on a product list page, users will usually see "Brand", "Price Range", "Color", and other filtering conditions, with each condition showing the number of products corresponding to each option under the current filtering result, which isarchiveFiltersWhat is provided.

In what scenarios should we prioritize?archiveFiltersInsteadarchiveParamsWhat? The answer lies in whether your core need is tobuild an interactive document filtering interface.

When your goal is to provide users with an intuitive, operable filter panel,archiveFiltersIt is your better choice. It directly provides the 'dimensions' and 'options' list required by the filter.For example, you are developing a job recruitment website where users can filter job listings based on conditions such as 'city', 'education', 'work experience', and so on.

  1. dynamically generate filter options:archiveFiltersit will return the 'city' field, itsitemsThe array contains specific city options such as “Beijing”, “Shanghai”, “Guangzhou”, etc. This isarchiveParamsa return ofvalue: "北京\n上海\n广州"This original string is more convenient, you do not need to manually parse the string, you can iterate through it directlyitemsArray to generate the front-end filter buttons or drop-down menus.
  2. Get the number of documents under the filtered optionsIf:archiveFiltersreturneditemsintotalIf the field has an actual value, it can also tell you how many matching documents there will be under the current conditions, such as "City: Beijing".This is crucial for user experience, allowing users to clearly see which filter conditions have content and avoid selecting empty results.
  3. A clearer definition of purpose:archiveFiltersClearly tell us which custom fields are designed to be used as filtering criteria. This helps us focus on building filtering functions rather than guessing whicharchiveParamsThe field can be used to filter.

On the contrary, if you just want to display all the details of a document (including its custom field values), or if you want to view the complete field configuration of a document model in the background tools,archiveParamsIt remains irreplaceable. It provides the "properties" of each field itself, rather than preprocessed "option lists" for dynamic filtering.

In summary, when you need to provide users withinteractive, selectable dynamic filtering functionalityand you want to display the matching count for each filtering option, without a doubt,archiveFiltersIt is your first choice. It can help you efficiently build a rich and user-friendly filtering interface.archiveParamsIt focuses more on obtaining the original structure and specific content of the document or model's custom fields.


Frequently Asked Questions (FAQ)

  1. archiveFiltersThe interface returnstotalWhy is the field sometimes 0? totalThe field indicates the number of documents included in the current filter condition. If all filter optionstotalIt shows 0, which usually means there are no documents under this model, or all documents do not meet the default filtering conditions that the system may exist (such as not published, not reviewed, etc.). In addition, if your project is new or has a small amount of data,totalThe value may be displayed as 0 due to lack of data.

  2. Can I usearchiveParamsThe custom field obtained after manual processing for filtering?Theoretically, it is possible.archiveParamsCan provide custom fieldsvalueFor examplevalue: "北京\n上海\n重庆"You can manually parse this string and split it into independent options. However, doing so will increase the complexity of the frontend logic, andarchiveParamsUnable to provide the number of documents corresponding to each option directly, which will greatly reduce the user experience of the filtering interface. Therefore, unlessarchiveFiltersUnable to meet your special requirements, it is not recommended to proceedarchiveParamsBuild a filter.

  3. If my custom field is not inarchiveFiltersreturned in the interface, what should I do? archiveFiltersOnly fields marked as 'filterable' in the AnQi CMS backend model management will be returned. If a field you want to use for filtering does not appeararchiveFiltersIn the result, you need to log in to the Anqi CMS backend, go to the corresponding "Document Model Management", find the custom field and edit its properties, make sure it is checked as "filterable". Save after that,archiveFiltersThe interface will return the field and its options.

Related articles

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 apply the filtering conditions obtained from the `archiveFilters` to the `archiveList` interface for document filtering?

In AnQi CMS, implementing the dynamic filtering function of documents is a key step to improve the user experience of the website.This usually involves close collaboration between two core interfaces: `archiveFilters` is used to obtain available filtering conditions, while `archiveList` is responsible for retrieving and displaying the corresponding document list based on these conditions.A deep understanding of how they work together can help us build flexible and user-friendly content filtering mechanisms for websites.### Understanding the Filtering Mechanism: From Definition to Discovery Imagine that your website has published a large number of articles

2025-11-09

Why does the `total` field often display as 0 in the `archiveFilters` returned data? What is its real purpose?

When using AnQi CMS for website content management, we often deal with various API interfaces.Among them, the `archiveFilters` interface is an important tool for obtaining document filtering conditions.Many users notice that when using this interface, the `total` field in the `items` list of the returned data always displays as `0` for each filter option (such as `Beijing` and `Shanghai` under `City`).This may be confusing: Since it's a 'quantity', why is it `0`? This

2025-11-09

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

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

In Anqi CMS, the `archiveFilters` interface is a very practical feature that allows us to retrieve the filtering conditions of specific document models, 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 products based on attributes such as 'color', 'size', or 'brand'. What if a document model is exactly configured without any filterable custom fields, what will the `archiveFilters` interface return?

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