Reveal the details of the Anqi CMS document inmodule_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. You may notice this in the returned data of the interface.module_idandcategory_idThese fields. They may seem to be just ordinary numeric IDs, but in fact, they are important clues for understanding the structure of the content and for efficient data operations.

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

module_id: The 'ID card' of the content model

In AnQi CMS,module_idRepresents the 'Content Model ID' of the document. The content model is the foundation of AnQi CMS flexibility, defining the basic structure and expandable fields of a category of content.For example, you might have a "article" model to publish news and blogs, a "product" model to display goods, and even a "case" model to present project experience.Each model has a unique ID.

From the document details interface (/api/archive/detail) 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: 1It 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 fully use the information obtained from the document details.module_idUsed as a request parameter to query specific information about the model. This includes the model name (title), the additional table name (table_name), and most importantly - all the custom fields defined under the model (fieldsThese custom fields define the unique attributes of the content, such as 'product model' may include 'price', 'inventory', etc., and 'article model' may include 'author', 'source', etc.

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

category_id: Navigation card of content categories

withmodule_idsimilar,category_idThe field indicates the "Category ID" of the document. Categories are the basic way of organizing content, which helps us to organize a large amount of content, making it convenient for users to browse and find.Under a content model, there can be multiple categories, and the categories can form a hierarchical relationship (for example, under the "News" category, there can be "Company News" and "Industry Dynamics" subcategories).

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: in the document detail interface of Anqi CMS, it returns thedatain fact, it has alreadydirectly contains the complete information of the document category, namelydata.categoryobjectThis means that you usuallydo not need to make an additional API requestto get its details (such as through/api/category/detailInterface). All categories, SEO information, URL aliases, and even the ID of the model they belong to are included (module_id) and the parent category ID (parent_id) are all there.

However,category_idIt is still very useful! If you want to:

  • Get the list of other documents in the same category:You can use thiscategory_idasarchiveListinterface'scategoryIdparameter to easily get other relevant documents in the same category.
  • Get all subcategories of a category:You can usecategory_idascategoryListinterface'sparentIdparameters to build a complete category navigation structure.

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


Frequently Asked Questions (FAQ)

1.module_idandcategory_idfield inarchiveDetailIs it a must in the interface return?

Yes, these two fields are inarchiveDetailThe returned data from the interface is the core attribute of the document, indicating the model and category to which the document belongs, which usually exists. If the document is not assigned a category,category_idIt may be a default or empty value, but it is not common in practice because categorization is the basis of content organization.module_idIt is almost always present, determining the content type of the document.

2. Can I search or filter documents according tomodule_idorcategory_idto search or filter documents?

Absolutely. Anqi CMS'archiveListThe interface (get document list) supports filtering 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 returned andata.categoryobject, why do I still needcategory_idThis independent field? Is it redundant?

data.categoryThe object indeed provides a complete detail of the current document category, avoiding the need for a separate query, which is to facilitate your access to all information of this category.category_idExists as an independent integer field, mainly for the convenience of indexing, querying, and parameter passing. For example, when requestingarchiveListorcategoryListan interface, directly pass an integer typecategoryIdIt is more efficient and concise to pass a complete classification object. They each have their own roles, complementing each other.