Revealing the details of the AnQi CMS documentmodule_idandcategory_idWhat do they really mean?

When using AnQi CMS for content management and website operation, we often obtain various data through API interfaces, including the document detail interface (/api/archive/detailIt is the key to obtaining the core information of a single article. In the returned data of this interface, you may notice thatmodule_idandcategory_idThese two fields. They may seem like just ordinary digital IDs, but in fact, they are important clues for understanding content structure and performing efficient data operations.

Next, let's delve into the meanings of these two fields and how they help us better utilize the AnQi CMS for content operation.

module_idThe 'ID card' of the content model

In the Anqi CMS,module_idRepresents the "Content Model ID" of the document.The content model is the cornerstone of the flexibility of AnQi CMS, defining the basic structure and extensible fields of a certain type of content.For example, you might have an 'Article' model to publish news and blogs, a 'Product' model to showcase products, and even a 'Case' model to present project experience.Each model has its unique ID.

From the document details interface (/api/archive/detail) return, we can see thatmodule_idthe field clearly indicates which content model the current document belongs to. For example:

{
  "code": 0,
  "data": {
    "id": 1,
    "title": "欢迎使用AnqiCMS",
    "module_id": 1, // 这里就是文档模型ID
    "category_id": 1,
    // ... 其他文档信息
  },
  "msg": ""
}

Heremodule_id: 1This may represent the 'article' model. Understanding this is crucial for our subsequent data operations.

Then, thismodule_idCan it be used to further query the details of the model?

The answer is affirmative! Anqi CMS provides the "Get Model Details Interface" (/api/module/detail), and you can definitely use the information obtained from the document details.module_idAs a request parameter, to query the specific information of the model. This includes the model name (title), the additional table name (table_name), and most importantly—the custom fields defined under the model (fields)。These custom fields define the specific attributes of the content, for example, the 'Product Model' may include fields such as 'price' and 'stock', while the 'Article Model' may include fields such as 'author' and 'source'.

By this means, you can dynamically understand the structure of any document and build more flexible frontend displays or perform more refined data processing accordingly. For example, you can according tomodule_idRetrieve model details and then render the unique filtering conditions of the model (such as through/api/archive/filtersthe interface, which also needsmoduleIdparameters).

category_id: Navigation cards for content categories

Withmodule_idis similar,category_id

Let us take another look at the returned data of the document details:

{
  "code": 0,
  "data": {
    "id": 1,
    "title": "欢迎使用AnqiCMS",
    "module_id": 1,
    "category_id": 1, // 这里就是文档分类ID
    "category": {     // 注意,这里已经包含了分类的详细信息!
      "id": 1,
      "parent_id": 0,
      "title": "AnqiCMS帮助",
      "seo_title": "",
      "url_token": "goruning",
      "module_id": 1,
      // ... 其他分类信息
    },
    // ... 其他文档信息
  },
  "msg": ""
}

Herecategory_id: 1Points to the category 'AnqiCMS Help'.

Then, thiscategory_idCan it be used to further query category details?

Here is a very practical detail: the document details interface of AnQi CMS returnsdataIn fact, it has alreadydirectly included the complete information of the category to which the document belongs, that isdata.categoryObjectThis means that for the classification of the current document, you usuallydo not need to make additional API requeststo retrieve its details (such as through/api/category/detailinterface). All categories' names, SEO information, URL aliases, and even their respective model IDs (module_id) and the parent category ID (parent_id) are all included.

However,category_idStill very useful! If you want:

  • Get the list of other documents under the same category:You can use thiscategory_idasarchiveListthe interface'scategoryIdparameter to easily get other related documents under the same category.
  • Retrieve all subcategories of a certain category:You can utilizecategory_idascategoryListthe interface'sparentIdparameters to build a complete category navigation structure.

In summary,module_idandcategory_idIt is the core identifier in the security CMS content system.module_idHelp you understand the structure of the content and custom attributes, andcategory_idThen responsible for the classification and navigation of the content.They together constitute the strong and flexible content organization capability of Anqi CMS, allowing developers and operators to accurately obtain and display content according to specific needs.


Common Questions (FAQ)

1.module_idandcategory_idis inarchiveDetailrequired to exist in the interface return?

Yes, these two fields are inarchiveDetailThe returned data of the interface is the core attribute of the document, indicating the model and category to which the document belongs, and they usually exist. If the document is not assigned a category, category_idThis might be a default or empty value, but it is not common in actual operation, because classification is the basis of content organization.module_idIt is almost always present and determines the content type of the document.

2. Can I search or filter documents according tomodule_idorcategory_idto perform a search or filter on documents?

Absolutely. The API of thearchiveListinterface (to get the document list) supports searching throughmoduleIdandcategoryIdAs a request parameter to filter documents.This means you can easily obtain all documents under a specific model or category, which is very useful for building category pages, special topic pages, or content aggregation.

3.archiveDetailthe interface has returneddata.category[en]Object, why is it still needed?category_id[en]This independent field? Isn't it redundant?

data.categoryThe object indeed provides complete details of the current document classification, avoiding the need for separate queries, which is to facilitate your access to all information of this classification.category_idExisting as an independent integer field, mainly for the convenience of indexing, querying, and parameter passing. For example, in the requestarchiveListorcategoryListinterface, pass an integer directlycategoryIdThey are much more efficient and concise than passing a complete classification object. They perform their respective functions and complement each other.