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

Calendar 👁️ 63

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.Let's learn together how to implement this feature in AnQi CMS.

Custom field: 'Living' tags of content

Firstly, we need to understand what a custom field is. In Anqi CMS, a custom field is an additional data item you add for a specific content model (such as articles, products, etc.).They can be text, numbers, single selection, multiple selection, dropdown menu, and more types.For example, if you operate a real estate website, you can add custom fields such as "type", "area", "location", etc. to the "House" content model;If you manage a job recruitment website, you can add fields such as "city", "education", "work experience", and so on.

These custom fields are not only used to store and display additional information, but also play a crucial role in becoming the key to users filtering content.By configuring it as a filter condition, you can upgrade your website from a simple content display platform to a powerful information retrieval tool.

Turn on the filtering feature: Backend configuration is key

Translate the custom field into a filter condition, the first step is to set it in the Anqí CMS backend management interface.You need to enter the model management page corresponding to the filter settings you want to configure.For example, if your article model needs to filter based on 'author' or 'publishing area', you will enter the field management of the article model.

In the model field settings, you will see that each custom field has a name called "Is filtering parameter" (is_filterThe option. This option is the key to the filtering function.After you check this option and save, AnQi CMS will recognize this custom field as a condition that can be used for filtering content lists.

It is worth noting that for fields with predefined options (such as radio buttons, checkboxes, dropdown menus), the values you enter when creating the field will automatically become specific options in the frontend filter.For example, if you set values such as 'Beijing, Shanghai, Guangzhou' for the 'City' field, then these city names will appear as options in the filter.

Get filter conditions: dynamically present user options

How does the front-end page know what filtering conditions and specific options are available after your custom field is configured for filtering? At this point, it is necessary to use the Anqi CMS providedarchive/filtersinterface.

By usingarchive/filtersThe interface sends a GET request and includes the filtering conditions you want to obtainmoduleId(Model ID), it will return a list containing all searchable fields. Each field will have its display name (name) and the actual name used in API calls (field_nameAnd a series of specific filtering options (items)

For example, if you request the filter conditions for model ID 1, the returned data may include two filter fields such as "City" and "Education", and each field lists specific options such as "Beijing", "Shanghai", "Master", and "Bachelor".This information can help you dynamically generate a filter form on the website front-end, where users can select predefined conditions without manual input.

Apply filter: Accurately obtain the desired content

After obtaining the list of filter conditions, the next step is how to apply these conditions to the actual content query to obtain a more accurate list of document lists.archive/listThe interface is the core to achieve this goal.

When callingarchive/listthe interface, in addition to the conventionalmoduleId/categoryId/orderparameters, you can also directly pass custom fields.field_nameAs a URL query parameter name, and pass the value of the option selected by the user as a parameter.

For example, if you want to find all articles with model ID 1 and "city" as "Beijing", your API request URL might look like this:

{域名地址}/api/archive/list?moduleId=1&city=北京

If you need to further filter the content with a 'Bachelor's Degree', you can continue to add parameters:

{域名地址}/api/archive/list?moduleId=1&city=北京&certificate=本科

By such a combination of parameters,archive/listThe interface returns only the content list that meets these filtering conditions, greatly enhancing the efficiency and usability of information search by users.

Summary

By following these steps, Anqi CMS's flexible custom field configuration combined with powerful API interfaces makes it easy to build websites with highly customizable filtering functions.This not only allows website administrators to organize and manage content more efficiently, but also provides end users with a more intelligent and convenient content browsing experience.


Frequently Asked Questions (FAQ)

  1. Ask: Can't all custom fields be used as filter conditions?Answer: Yes, only when the 'Whether to filter parameters' option is explicitly checked in the Anqi CMS background model management (is_filterCustom field of the option must be selected to passarchive/filtersUsed to get through the interfacearchive/listContent filtering is performed through the interface. Fields not checked can be used for content display but cannot be used as filtering conditions.

  2. How to handle the logic of the 'All' option in front-end filter conditions?Answer:archive/filtersEach filter condition list returned by the interface usually contains alabel: "全部"The option. In practice, when the front-end user selects "All", you just need to callarchive/listWhen interfacing, omitting the parameter for the screening condition is sufficient, the system will automatically return all content without limitations for that condition. For example, if the user selects “City: All”, then inarchive/listDo not include in the requestcityParameter.

  3. Question: If my custom field is a multi-select type, how should I pass the filter parameters?Answer: For multi-select custom fields, Anqi CMS usually supports selecting multiple values by separating them with commas as

Related articles

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

How to interpret the `items` array in the filtering conditions API, used to build the front-end filter?

In modern web design, the content filtering feature has become an important part of improving user experience and content discoverability.A well-designed filter can help users quickly locate the information they are interested in, whether it is products, articles, or any other form of content.For Anqi CMS, the provided filtering conditions API (/api/archive/filters) is the foundation for building such frontend filtering functions.Especially the `items` array in the response data is the key to understanding and implementing dynamic filtering.

2025-11-09

What do the `name` and `field_name` in the `archiveFilters` interface represent?

During the development and content management process of Anqi CMS, we often need to handle document filtering and display.The `archiveFilters` interface was born for this purpose, it provides the ability to dynamically obtain filtering conditions.Understand the `name` and `field_name` fields in the returned data, which are crucial for building flexible and versatile front-end filtering functions.

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

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

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