In AnQi CMS, the flexibility of document content management is a highly关注的 feature, especially its support for custom fields (manifested in the interface returns)extraSupport for fields within) provides great convenience for website operators. When we need to filter and search through a large number of documents based on these custom properties, a key issue naturally arises: the document list interface of Anqi CMS (/api/archive/listDoes it support more complex queries on the returned data'sextrafields?
To answer this question, we need to understand deep intoextrathe nature of the field and the query mechanism provided by the SafeCMS.
UnderstandingextraField and custom content
In the document details and document list interfaces of AnQi CMS (such as/api/archive/detailand/api/archive/listthe returned data in the following, extraA field is a very important component.It is not a fixed data structure, but rather a dynamically generated one based on the custom fields you define for a specific document model (such as an article model, product model, etc.).
In simple terms, when you add a field named "author" (with the nameauthor), and a field named "city" (with the namecityAfter the custom field )is added, these fields will appear in the object when document data is retrieved through the API.extraThe structure is usually{ "field_name": { "name": "字段名称", "value": "字段值", "default": "默认值" } }. This meansextraThe field is an important carrier of personalized content on your website.
Query capability of the document list interface
Document list interface of Anqi CMS/api/archive/listProvides various parameters to filter and sort documents, such asmoduleId(Model ID),categoryId(Category ID),order(Sort method) andq(Keyword search) and these are common query methods that can meet most routine needs.
While forextraField query, Anqi CMS takes a clever and practical method, namely throughCustom filter parametersto achieve. The document clearly states:
"Filter parameters are only available in list types
type="page"becomes effective, if there are configurable fields in the document extra automatic configuration, you can use these parameters to complete parameter-based filtering of the document. If your document is set to automatically filter by gender, with default values of Male, Female, and Confidential, you can pass these through the URL query parametersgender=男Search the document.genderThe field is the male document content.”
This is the core answer to the problem. This means that you cannot directly accessextraThis complete JSON object performs complex queries similar to database statements (such as, queryingextrainvalueall fields containing a specific substring), but you can handle those inThe field is set to 'Filterable' custom field in the backendPerform an accurate key-value pair matching query.When you add these custom field names as query parameters in the URL, the Safe CMS will filter documents based on these parameters and return a list that meets the criteria.
How to use custom filter parameters?
- Backend configuration:Firstly, you need to set the custom field that needs to be used for filtering to 'filterable' in the field management of the document model in the AnQi CMS backend.
- Found filterable fields:If you are unsure which fields are filterable, or want to know their
field_name(Call name) and possible options, you can use/api/archive/filtersInterface. This interface can return all field information configured as filterable under a specified model, including the field name (name), the call name (field_name) and the available options (itemsThis is very helpful for building dynamic filters on the front-end page. - Initiate query:After you have mastered the naming of custom fields, you can in the interface request,
/api/archive/listwithfield_name=valueThe format as URL query parameters. For example, if you have a call namedcitya custom field, and want to query all documents with the city of “Beijing”, you can construct the request parameters ascity=北京.
Summary
Document list interface of Anqi CMSSupportForextraQuery the custom fields contained in the field, but this query is not a direct operationextraThe complex structure within the field is instead achieved by setting the custom field name configured as 'filterable' in the backend as a URL query parameter to achieve precise matching.This design ensures both the performance and security of the API, while also providing sufficient flexibility for website operators to perform refined content filtering and display based on custom content.
By fully utilizing this mechanism, you can build a feature-rich and user-friendly filtering function on the front end, helping users quickly find the specific content they are interested in.
Common Questions (FAQ)
What: Does the custom field support default support for
/api/archive/listfiltering in the interface?Answer: No, custom fields do not support filtering automatically by default.You need to explicitly check the 'Filterable' option in the document model management on the Anqi CMS backend for each custom field that you want to be filterable./api/archive/listin the interface usage.What: Can I filter
extraPerforming 'greater than', 'less than' such range queries on the numeric type in the field, for example, querying documents with a price higher than 1000?Answer: Based on the current document description, the Anqi CMS's/api/archive/listinterface mainly supports the exact matching query of custom fields (i.e.field_name=value). It does not directly provide a target forextraThe built-in parameters for querying numeric type fields with 'greater than', 'less than', or range queries.If you have this requirement, you may need to consider performing a secondary filter after obtaining the data on the front-end, or contacting the Anqi CMS official for customized development support.Question: If my custom field is a multi-select type, for example, a document can be associated with multiple tags (in
extraHow can I query documents containing any of the tags that exist in the form of commas or other formats?Answer: For multi-select custom fields, you can/api/archive/filtersview them through the interfaceitemsTo understand the specific query support methods, please refer to the 【en】筛选参数列表. In most cases, if a multi-select field is set to be filterable, it may support exact matching of one of the options, or in some implementations, it may allow multiple values to be represented as an 'OR' relationship by separating them with commas (e.g., `tags=标签`)