As an experienced website operations expert, through my practice with AnQiCMS, I deeply understand that its flexible and powerful content management capabilities are the cornerstone of website success. Today, let's delve into a seemingly simple but highly flexible core mechanism:categoryListThe label corresponds to the classification field in the background "content model" settings.Understanding this can help you better control the presentation of website content, achieving truly customized operation strategies.


The blueprint role of content models

To understandcategoryListLabel, we first need to talk about the core concept of AnQiCMS - the 'Content Model'.In AnQiCMS, the content model is like the 'blueprint' or 'template' for different types of content on your website.It defines which fields and properties a certain type of content should include.For example, an "article model" may include fields such as "article title", "publish date", "author", and "content", while a "product model" may include fields such as "product name", "price", "inventory", and "product image set".

The strength of AnQiCMS lies in the fact that these models not only have built-in common fields but also allow you to highly customize according to actual business needs, adding unique fields such as 'article source', 'product color', 'house type', etc.These custom fields will become additional information that can be filled in when you publish specific content (documents).

Classification: the 'location' and 'personalized description' of content

After having the 'blueprint' of the content model, the next step is how to organize these contents - this is the responsibility of 'classification'. In AnQiCMS, each category mustand onlyBelongs to a specific content model.For example, you can create a category named "Industry News" and associate it with the "Article Model"; then create a category named "Smartphone" and associate it with the "Product Model".

This relationship is crucial because it determines that all future content (documents) to be published under this category will follow the field definitions of the content model it belongs to.For example, all articles under the "Industry News" category will have an "author" field; all products under the "Smartphone" category will have a "price" field.

However, the category itself, in addition to being the 'place of origin' for the content, also possesses some attributes and information.For example, the name of the category, introduction, SEO information, and even for the need of page beauty and content presentation, you can also set a "Banner image" or "thumbnail" for the category.Add custom field extra.For example, you can add a "Brand Introduction" field or a "Sales Manager" field under the "Product Model" category, so that each product category can have its own unique description information.

categoryListThe 'connector' role of the tag

Now, let's turn our attention to the template level. On your website's frontend page, you need to display these categories for navigation or browsing.categoryListThe tag is the powerful "connector" provided by AnQiCMS for this purpose.

When you usecategoryListFor example, when labeling{% categoryList categories with moduleId="1" parentId="0" %}You are actually giving commands to AnQiCMS:

  1. moduleId="1": Clearly tell the system that I need to listContent model ID is 1All categories under (for example, "Article Model"). This iscategoryListThe tag has the most direct association with the background content model settings. By specifyingmoduleIdYou can accurately obtain all categories belonging to a specific content model, thereby realizing independent display and management of different types of content categories on the front end.For example, you can only display article categories on the article list page, and only product categories on the product center page.
  2. parentId="0": it indicates that you want to retrieve the model undertop-level categories. You can also specify a specificparentIdto retrieve subcategories, or even useparentId="parent"To get the sibling categories of the current category, this reflects its flexibility in building multi-level category navigation.

WhencategoryListAfter the label is executed, it will return a list containing multiple category objects (in the above example, it iscategories). For each category object, you can access its built-in fields, such as:

  • item.IdCategory ID
  • item.Title: Category Name
  • item.Link: URL Link for Category
  • item.Description: Category Description
  • item.ParentId: Parent Category ID
  • item.Logo: Category Banner Image (if uploaded in the backend)
  • item.Thumb: Category thumbnail (if you have uploaded one in the background)
  • item.ArchiveCount: Number of documents included in the category
  • and,The category itself is defined by any custom fields defined by the associated content modelThis means that if you define additional fields (such as a text field namedcategory_sloganfor the entity “Classification” in the content model settingcategoryListthen each one traversed out will beitemAlso includesitem.category_sloganSuch properties, for flexible front-end calls.

Summary: The foundation of refined operation

In short,categoryListLabels and the classification fields related to the background content model exist in a mutually dependent mapping relationship. The content model defines the structure of the content and the fields that can be expanded for classification, while the classification itself specifies the concretization and hierarchization of the content model.categoryListThe tag is responsible for accurately extracting and presenting the structured, hierarchical classification information, along with the built-in and custom attributes it contains, on your website front-end.

This design pattern gives AnQiCMS great flexibility and customizability. It allows website operators to:

  • Display as needed:Based on content type (determined by the content model) filter and display related categories.
  • Customized presentation: By adding custom fields to categories, different categories can have unique descriptions and visual elements.
  • Optimize user experience and SEO: A clear classification structure and rich and accurate classification information, not only improves user navigation efficiency, but also provides a more friendly crawling path and richer content context for search engines.

Mastering this correlation, you can better plan the information architecture of the website, design more attractive and business-demand-oriented web pages, and stand out in the fierce online competition.


Frequently Asked Questions (FAQ)

  1. Ask: Can a category belong to multiple content models at the same time? Answer:Do not.In the design of AnQiCMS, each category is strictly limited to belong to only one content model.Once the category is created and the content model is selected, the association cannot be changed.This is to ensure the clarity and consistency of the content structure.

  2. Ask: If I define a new field (such as 'Article Summary') for the 'Article Model' in the background, then when usingcategoryListCan you directly access this 'article summary' field when listing article categories? Answer: categoryListThe tags directly list isThe category itselfand the properties it inherits through the content modelcustom fields of the category. It does not directly expose the custom fields of the documents under the category (such as "Article Summary"). If you need to access the custom fields of the document, you need tocategoryList