When using AnQiCMS for website content management, we often need to deal with API interfaces related to documents.archiveParamsandarchiveFiltersThese two interface names sound similar at first hearing, both related to 'document parameters', but they have entirely different functions and usage scenarios in actual application.Understanding the differences between them can help us develop and manage websites more efficiently.

Deep understandingarchiveParamsInterface: Get detailed parameters of a specific document

Imagine you are browsing a product detail page. In addition to the basic information such as product title, description, and images, you also want to see additional information such as "brand", "material", and "suitable population" that is customized by the backend.archiveParamsThe interface comes into play.

archiveParamsThe purpose of the interface isThe actual value of the custom parameters set for a specific document (archive)。它需要你提供一个文档的唯一标识,通常是文档ID (id). When you call this interface and specify a document, it will return the names of all custom fields of the document, the actual values filled in, and the default values.

For example, if you have customized the 'author' and 'city' fields in your article model, when you retrieve an article with ID 123,archiveParamsWhen, you might get such information:)

  • The "author" field, its value is "Anqi CMS Team"
  • The "city" field, its value is "Beijing"

Here is the custom content you entered for the specific article when you edited the article.This interface is usually used to supplement the content of non-standard fields when displaying the detailed information of a single document on the front end.sorted=true)or an unordered objectsorted=false) form to obtain these parameters, so that they can be flexibly traversed or accessed directly in the template.

In simple terms,archiveParamsIt's like flipping through the 'flyleaf' of a book, telling you what specific features this book has.

Deep understandingarchiveFiltersInterface: Get the filtering conditions of the document module

whilearchiveFiltersThe interface has a completely different responsibility. It does not focus on the parameter values of a specific document, butProvide a list of available filter conditions for a document model (module).Imagine you are on a product list page of an e-commerce website, where there are usually options like 'Filter by brand', 'Filter by price range', 'Filter by color', etc.archiveFiltersObtained through the interface.

archiveFiltersThe interface requires you to specify a model ID (moduleIdEnglishIt will return all the custom fields marked as filterable under the model, as well as the list of options that may be included in these fields.archiveFiltersPass the model ID and you will get:

  • A filter named 'City' including options such as 'Beijing', 'Shanghai', 'Chongqing', etc.
  • An 'Education' filter with options such as 'Master', 'Bachelor', 'Junior College', etc.

These returned "cities" and "educationGeneral Conditions. Front-end developers will use this information to dynamically build filter menus, and after the user clicks on these options, they will combinearchiveListthe interface to request a list of documents that meet the conditions.

In plain English,archiveFiltersIt's like the 'cataloging system' of a library, telling you how all the books in the library can be searched by categories and themes.

Core Difference Summary

  • Focus on different subjects: archiveParamsFocusSingle documentCustom information ofarchiveFiltersFocusFilter conditions for all documents under a specific document model.
  • Different content returned: archiveParamsThe one returned is a specific document ofActual parameter value;archiveFiltersThe document model returned is available for filteringField definition and option list.
  • Different application scenarios: archiveParamsIt is commonly used forDocument details pageDisplay;archiveFiltersIt is commonly used forDocument List PageBuild a filter or search interface.
  • Different request parameters: archiveParamsDependenceidorfilenameLocateSpecific document;archiveFiltersDependencemoduleIdLocatedocument model.

Understood the boundaries between these two, you can plan the front-end and back-end interaction logic of the security CMS more clearly. Whether it's displaying detailed document content or building flexible filtering functions, you can handle it with ease.


Common Questions (FAQ)

1.archiveParamsCan the interface be used to filter the document list?No.archiveParamsThe initial design of the interface is to obtain detailed custom parameters of a single document, it does not have the function of filtering multiple documents. If you need to filter a list of documents based on the value of a custom field, you should usearchiveListInterface, and cooperate with its supported custom filtering parameters.archiveFiltersInterface can tell youarchiveListThe interface supports which custom filtering parameters and their optional values.

2. WhyarchiveFiltersIn the filtered options returned by the interface,totalAre all the values in the field 0?In the document example you provided,totalField display as 0, which usually indicates that the interface does not perform real-time statistics of the number of documents under each filtering option when returning the filtering condition structure. In actual project use, the front-end may call these filtering conditions after obtaining them.archiveListInterface (usually passed in)type=pageand setlimitas 0 or 1) to count the number of documents matching each filter condition, so that numbers like "(50)" can be displayed next to the filter.

How can I know if a custom field can bearchiveFiltersobtained through the interface?custom field can bearchiveFiltersThe interface retrieves this, depending on whether this field is marked as "filterable" in the model settings of the AnQi CMS backend. Only fields that are set as "filterable" will appeararchiveFiltersThe result appears as an option for users to perform filtering operations on the front end.