When using AnQiCMS for website content management, we often need to deal with API interfaces related to documents. Among them,archiveParamsandarchiveFiltersThese interface names sound similar at first hearing, both are related to "document parameters", but they have completely different functions and usage scenarios in actual applications.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, besides the basic information such as product title, description, and images, you also want to see additional information such as 'brand', 'material', 'suitable population', which are customized by the backend. At this time,archiveParamsThe interface is put to use.
archiveParamsThe purpose of the interface is.The actual value of the custom parameters set for a specific document (archive). It requires you to provide a unique identifier for the document, typically the document ID (id). When you call this interface and specify a document, it will return the names of all custom fields, the actual values entered, 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,archiveParamsYou may receive such information:
- The "author" field, its value is "AnQi CMS Team"
- The "city" field, its value is "Beijing"
The 'author' and 'city' here are the custom content you enter while editing this specific article.This interface is usually used to display detailed information about a single document on the front-end, supplementing those non-standard fields.You can choose to use an ordered array(sorted=true)or unordered objects(sorted=falseThese parameters are retrieved in the form so that they can be flexibly traversed or accessed directly in the template.
In simple terms,archiveParamsIt's like looking at the 'flyleaf' of a book, which tells you what unique information this particular book has.
Deep understandingarchiveFiltersInterface: Get the filtering conditions of the document module
AndarchiveFiltersThe interface has a completely different responsibility. It does not focus on the parameter values of a specific document, but ratherProvide a list of available filtering conditions for a document model (module). Imagine you are on the product list page of an e-commerce website, where you typically have options like 'Brand Filter', 'Price Range Filter', 'Color Filter', etc.These filtering conditions themselves are passed througharchiveFiltersobtained through the interface.
archiveFiltersThe interface requires you to specify a model ID (moduleIdIt will return all the custom fields marked as filterable under the model, as well as the option lists that these fields may contain.For example, if you have a "job recruitment" model that defines "city" and "education" as filterable fields, then you callarchiveFiltersPass the ID of the model, and you will get:
- A filter named "City" that includes options such as "Beijing", "Shanghai", "Chongqing", and so on.
- A filter named 'Education' including options such as 'Master', 'Bachelor', 'Junior College', etc.
These returned 'cities' and 'education' options are not the specific content of a single recruitment document, but you can use them throughout the 'Job Recruitment' module to filter document listsGeneral condition. Front-end developers will use this information to dynamically build filter menus, after the user clicks on these options, then combinedarchiveListthe interface to request document lists that meet the conditions.
In plain language,archiveFiltersIt's like the 'classification label system' in a library, which tells you how all the books in the library can be searched by categories and themes.
Summary of the core differences
- Focus on different objects:
archiveParamsFocusa single documentCustom information;archiveFiltersFocusFilter conditions of all documents under a certain document model. - The returned content is different:
archiveParamsThe returned is specific document'sActual parameter value;archiveFiltersThe one returned is the document model that can be used for filteringField definition and option list. - Different application scenarios:
archiveParamsGenerally used forDocument detail pageDisplay;archiveFiltersGenerally used forDocument list pageBuild a filter or search interface. - The request parameters are different:
archiveParamsDependencyidorfilenamePositioningSpecific document;archiveFiltersDependencymoduleIdPositioningDocument model.
Understanding the distinction between these two allows you to plan the front-end and back-end interaction logic of AnQi CMS more clearly, whether it is to display detailed document content or build flexible filtering functions, you can do so with ease.
Frequently Asked Questions (FAQ)
1.archiveParamsCan the interface be used to filter the document list?No.archiveParamsThe design of the interface is to obtain the 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.archiveFiltersThe interface can tell you.archiveListWhat custom filtering parameters and their optional values the interface supports.
2. WhyarchiveFiltersAmong the filtering options returned by the interface,totalAre the values in the field all 0?In the document example you provided,totalThe field displays as 0, which usually indicates that the interface does not count the number of documents under each filtering option in real-time when returning the filtering condition structure. In actual project use, the front-end may call these filtering conditions after obtaining them.archiveListInterface (usually passed intype=pageand setlimitas 0 or 1 to count the number of documents matching each filter condition, thus displaying numbers like “(50)” next to the filter.
3. How can you know if a custom field can bearchiveFiltersretrieved through an interface?retrieved through an interface?archiveFiltersThe interface retrieves it, depending on whether the field is marked as 'filterable' in the AnQi CMS backend model settings. Only fields set as 'filterable' will appear inarchiveFiltersThe result appears, as an option for users to perform filtering operations on the frontend.