How to query all custom field information contained in a model (such as an article model)?

Calendar 👁️ 84

The AnQi CMS, with its powerful content model and flexible custom field features, provides great convenience for website operators.These custom fields are the key to personalizing website content and structuring data.How can you accurately query all the custom field information contained in a specific model (such as an article model)?This is very useful when conducting secondary development, data connection, or just to understand the system structure.

In AnQi CMS, the most direct and effective way to query all custom field information contained in a model is throughthe interface to get model details (/api/module/detail)to query.

Learn about custom fields by accessing the model detail interface

When you need to understand the custom field definition of a specific model (such as an article model or product model), you can use this interface. You just need to provide the model's ID or its alias (filename), you can obtain all the detailed information of the model, including the custom fields we are concerned about.

The calling method of this interface isGET, one of the following parameters needs to be passed in:

  • id: The unique identifier of the model, an integer value.
  • filename: The URL alias of the model, a string.

For example, if you know the ID of the article model is 1, you can construct the request like this:{域名地址}/api/module/detail?id=1.

In the data structure returned by the interface, there is adataarray under the object.fieldsThis array.fieldsThe array is the complete definition of all custom fields under the model. Each array item represents a custom field and includes the following key information:

  • name(Field Chinese name)This is the intuitive name you see when setting up in the Anqin CMS backend, convenient for content editors to understand.
  • field_name(Field Name)This is the unique identifier called in the program, usually used for template tags, front-end rendering, or specifying fields through API data interaction.
  • type(Field type)It indicates the data type of the field, for exampletext(Text),number(Number),textarea(Multi-line text),radio(Single selection),checkbox(Multiple choice),select(Dropdown selection) etc. Understanding field types helps you properly handle and display data.
  • required(Mandatory): This is a boolean value (trueorfalse), indicating whether the field is required when publishing content.
  • is_system(Is it a system built-in field): It is also a boolean value,trueThis indicates that it is a core field of the system,falseIt means that it is a field added by the user.
  • is_filter(Filter parameter): This attribute is very useful, if it istrueThis field can be used as a filter condition in the front-end content list, and users can filter content through the value of this field.
  • follow_level(Whether to follow the document reading level): If it istrueThis means that the visibility of this custom field will be restricted by the document reading level.
  • content(Default Value)If the field is configured with a default value when the model is set, then this property will display the corresponding default content.For dropdown selections, radio buttons, multiple choices, etc., an options list may be included here.

By parsing thisfieldsAn array, you can clearly understand the names, types, whether mandatory, and other important properties of all custom fields under a certain model.

Query all models and their custom fields

If you want to get a comprehensive overview of all models and their custom fields at once, or if you are unsure of a specific model's ID or aliasThe interface to get the list of models (/api/module/list)will be a good helper for you.

The calling method of this interface isGETAnd without any parameters, it can return a detailed list of all content models in the system. In the returneddataarray, each element is a model object, which also containsfieldsAn array with a structure获取模型详情接口The field definitions returned are consistent. This allows you to iterate through all models and view their custom field definitions one by one.

Understand the custom field values in the document.

After understanding the definition of custom fields, we might want to know how to view the actual content filled in for these custom fields in a specific article or product. This can be done byInterface to get document details(/api/archive/detail)orInterface to get document list(/api/archive/list)to achieve.

In the return data of these two interfaces, you will see a namedextrathe object.extraobject withfield_name => itemThe form shows the actual values of all custom fields.itemObjects usually contain:

  • name: The Chinese name of the custom field.
  • value: The actual content filled in for this custom field in the document.
  • defaultThe default value of this field (if it exists).

By combining the use of the aforementioned several API interfaces, whether it is to obtain the field definitions of the model or to query the field values of specific content, Anqi CMS provides a clear and convenient way for you to flexibly manage and utilize the structured content of the website.


Frequently Asked Questions (FAQ)

  1. Q:is_filterWhat is the actual use of the field?A:is_filterThe field indicates whether a custom field can be used as a filter condition on the website frontend. For example, if your article model has a custom field named "city", and itsis_filterWithtrueThen on the article list page, you can filter articles based on the value of the "city" field, making it convenient for users to quickly find articles related to specific cities.
  2. Q: Why am I获取文档详情interface'sextraCan't see a custom field inside the object?A:extraThe object only contains thoseThe content has been filled inOrThere is a default valueThe custom field. If a custom field is defined in the background model but no content is filled in the specific document and no default value is set, it will not appear in the document.extraIn the object.
  3. Q:field_nameandnameWhat is the difference? Which one should be used in development?A:nameIs the custom field's Chinese display name, mainly used for the background management interface and to provide content editors with intuitive identification.field_nameIs the unique identifier of the field, used internally in the program, in API request parameters, and in template tags. You should always use it, especially when interacting with data through APIs.field_nameAccurately refer to and operate custom fields.

Related articles

How does the key-value pair structure (`key => item`) in the document details correspond to the backend custom field settings?

When using AnQi CMS to manage website content, you often see a field named `extra` in the data returned by document detail or document list interfaces (such as `archiveDetail` and `archiveList`).This field is specifically used to carry custom information we set for the document model.Understanding the structure of the `extra` field and its correspondence with backend custom fields is crucial for front-end development and content management.

2025-11-09

How to handle the display of front-end images if the `thumb` or `logo` field returned by the document detail interface is empty?

When building a website with AnQiCMS, we often retrieve detailed document information from the backend interface.Among them, images are an indispensable part of content display, and the `thumb` (thumbnail) and `logo` (logo) fields are particularly important, as they are usually used in article lists, the top or sidebar of detail pages, and other locations.However, in actual development, we may encounter situations where these fields return empty.How should we handle it elegantly when the front-end gets an empty value, to ensure the friendliness of the user interface (UI) and the integrity of the content

2025-11-09

How to use the `url_token` in the `category` object to build the link of the category?

Building clear and accessible links for your website content in Anqi CMS is a key factor in optimizing user experience and search engine rankings.Among them, using the `url_token` in the `category` object to build category links is an efficient and SEO**compliant method.Understand the role of `url_token` in category links `url_token` is a unique identifier provided by Anqi CMS for each category, usually a short, descriptive English word or pinyin

2025-11-09

Why does the document detail have `price` and `stock` fields, even though the document is not a product type?

When using AnQiCMS to manage website content, many users may notice a phenomenon: even for ordinary articles, news, and other non-product type documents, the returned data structure still contains the `price` (price) and `stock` (inventory quantity) fields when their details are retrieved through the API.This may seem confusing at first glance, but after understanding the design philosophy of AnQiCMS, it will be found that this is exactly the embodiment of its powerful flexibility and scalability.AnQiCMS is designed at the bottom level

2025-11-09

How to implement reading level control for specific documents (such as paid documents) in Anqi CMS?

In AnQi CMS, implementing a reading level control (`read_level`) for specific documents (such as paid documents or exclusive member content) is a very practical feature. It helps us better manage content permissions and achieve differentiated content operations.This mechanism is not only flexible, but also closely integrated with the user system, allowing us to determine what content users can see based on their identity or payment status. Next, we will explore how to efficiently use `read_level` in Anqi CMS to implement document access control.###

2025-11-09

How should the comment area on the document detail page be integrated with the Anqi CMS comment API to display and publish comments?

In website operation, the comment area of the document detail page plays an important role, it not only promotes user interaction and enhances content activity, but also brings new content and search engine visibility to the website.AnQiCMS provides a powerful and easy-to-integrate comment API that allows you to easily implement comment display and posting features on your website.This article will discuss in detail how to use these APIs to create a fully functional comment system for your document detail page.##

2025-11-09

How to optimize the navigation experience of the previous and next documents through the `archivePrev` and `archiveNext` interfaces?

Today, with the increasing refinement of content management, every detail of a website may affect the reading experience of users.Among them, the navigation between the previous and next documents, as an important part of guiding users to continuously explore the website content, should not be overlooked in terms of convenience and fluidity.AnQiCMS (AnQiCMS) knows this and provides the powerful and intuitive interfaces `archivePrev` and `archiveNext` to help us easily implement and optimize this feature.###

2025-11-09

How to get the parameter filter condition list of a specified document model?

In website operation, providing users with a convenient content filtering function can significantly improve user experience and content discovery efficiency.The Anqi CMS provides powerful interfaces, allowing us to flexibly obtain and utilize these filtering conditions.Today, let's discuss how to get the parameter filtering condition list of a specified document model in Anqi CMS. ### The Importance of Understanding Filtering Criteria Imagine if your website has many products or articles, and users want to search based on dimensions such as "city", "education", or "product type".

2025-11-09