As an experienced website operation expert, I am well aware that the core value of a Content Management System (CMS) lies in the seamless connection between its backend configuration and frontend display.The AnQiCMS (AnQiCMS) performs particularly well in this aspect, thanks to its efficient architecture based on the Go language and flexible design.categoryListTags, how closely they correspond to the background "Document Classification" function, and how we can ingeniously utilize this association to build powerful website functions.
English: The "Document Classification" feature: building the skeleton and order of content
In the background management interface of AnQi CMS, the "Document Category" function is the cornerstone of organizing website content.It is not just a simple categorization of articles, products, and other content, but also provides a clear and logical hierarchical structure for these contents.Imagine your website as a library, where document categories are like the shelves and sections in a library, and each book (document) must be placed on a specific shelf.
When you create or edit a document category in the background, Safe CMS provides an extremely rich set of configurable options, which together define the characteristics and behavior of a category:
- Document Model (Content Model)This is the soul of the category.Each category must be bound to a content model, such as "Article Model" or "Product Model", and once bound, it cannot be changed.This choice determines what data structure all documents under this category will follow, and which fields they will have (such as authors for articles, prices for products, etc.).
- Parent Category (Parent Category):By setting the parent category, you can easily build a multi-level category structure, such as "News Center" under "Company News" and "Industry Dynamics".This is crucial for the navigation and content aggregation of the website.
- 分类名称、简介(Title, Description)This is the basic information displayed to users and search engines for categorization, which directly affects users' understanding of the category content and SEO effects.
- Custom URL (Custom URL) and SEO related settings:Allow you to set friendly URLs for categories, and configure independent SEO titles and keywords to further optimize search engine inclusion.
- 分类模板、文档模板(Category Template, Document Template)These settings determine which template file the system will call to render the page when the user accesses the category page or the document detail page under the category.This high degree of customization allows you to design completely different visual styles and layouts for different types of categories.
- Banner image, thumbnail: Provides visual elements for category pages, enhancing aesthetics and attractiveness.
- Category ContentEnglish: Allows you to directly add rich text content to categories, which is very useful when creating pages like 'About Us' or those with introductory text.
In short, the "Document Classification" feature on the backend is a comprehensive content organization and metadata definition center, laying a solid foundation for the website's content structure, display logic, and search engine optimization.
Template incategoryListLabel: Displaying Category Data
When you are developing templates for the Anqi CMS,categoryListThe label is the key bridge connecting the "Document Category" on the backend with the front-end page display.It is a powerful data acquisition tool that allows developers to dynamically extract categorized data from the background and present it on the website in a highly flexible manner.
categoryListThe core function of the label is to traverse and display the classification information you set in the background. It is usually wrapped in a{% categoryList categories with ... %}and{% endcategoryList %}structure, wherecategoriesThis is the variable name you define, used to represent the obtained category list in the loop.
This tag uses a series of parameters to accurately filter and control which categories to obtain.
moduleIdThis parameter directly corresponds to the 'Document Model' selected for the category in the background 'Document Classification'. It is specified through the use ofmoduleId="1"(Assuming 1 is the article model ID), you can only get all categories belonging to the article model.This corresponding relationship ensures that the classification data obtained by the front-end is consistent with the data structure of the back-end.parentIdIt is closely related to the "parent category" setting on the backend. You can setparentId="0"Get all top-level categories, or specify an ID of a specific category to get all its subcategories. This parameterized capability makes it easy to build multi-level navigation menus.limit:Control the number of returned categories, which helps optimize page loading and display layout.all:When set toall=true, all categories will be retrieved, ignoring the hierarchical relationship.
IncategoryListTags loop inside, each category data item (in our example isitemAll of them expose rich properties, which directly map to the various information you filled in under the "Document Category" on the backend:
item.Id/item.Title/item.Description: correspond to the ID, name, and description of the category on the backend.item.LinkThis is the category page link, which is automatically generated based on the 'Custom URL' set in the background 'Document Category' and the pseudo-static rules of the website, ensuring the correctness of the front-end link.item.Logo/item.Thumb:对应后台为分类上传的缩略图和大图(Banner图通常通过自定义字段或EnglishcategoryDetail获取)。item.HasChildren:An extremely useful boolean value used to determine whether the current category has subcategories. This can control whether to display the dropdown arrow or submenu when building a dynamic navigation menu.item.ArchiveCount:Display the number of documents under this category, convenient for content statistics and display.
Reveal Deep Connections: How backend configuration drives frontend display.
categoryListLabel correspondence between the tag and the background "Document Classification" function is the core embodiment of the flexibility of Anqi CMS. They together constitute a powerful content management and publishing system:
Data source and consumer: The "Document Category" backend is the producer and manager of the original data, defining all attributes of the category; and
categoryListThe label is the consumer of these data, it intelligently extracts and formats these data from the background database according to the needs of the template developer.Structured and dynamic:The "Document Classification" feature in the background forces you to manage content structurally, bind content models, and establish a hierarchical relationship.
categoryListTags utilize this structured information to dynamically build various modules such as navigation, category lists, content aggregation on the front-end, without hardcoding, which greatly improves development efficiency and maintainability.When you adjust the category name, level, or replace the associated model in the background, the front-end page will synchronize the update immediately after clearing the cache, without the need to modify any template code.Parameter precision control:
categoryListofmoduleIdParameters, allowing you to easily filter out specific content models, such as displaying a list of "News Articles" categories on one page and a list of "Product Catalog" categories on another page.parentIdParameters can accurately control the level of the categories obtained, whether it is top-level navigation or sidebar subcategories, all can be achieved through simple parameter configuration.Content separation from presentation:Background is responsible for defining 'what' and 'having what', while the front-end template is responsible for 'how to display'. For example, you set 'category template' for a certain category in the background.
special_list.htmlThen when the user accesses this category page, the Safe CMS will load this specific template.categoryListThe label's role is to list its name, link and other information when this category is listed on other pages (such as the homepage, sidebar).Build complex navigation and content index:Benefited by
categoryListthe good support for the hierarchical relationship(parentIdanditem.HasChildren),we can easily build responsive multi-level dropdown menus in templates. Through nestingcategoryListTags, can realize infinite-level classification navigation, providing users with a clear website structure.
Practical Application: Bring into playcategoryListthe power
MasteredcategoryListCorrespond to the "Document Classification" on the backend, and you can achieve various flexible content displays in the Anqi CMS:
- Main navigation menu: Utilizing
moduleIdandparentId="0"Get the top-level category, combineditem.HasChildrenDetermine if there is a subcategory and then use it nested.categoryListTo build a multi-level dropdown menu. - Sidebar category list: Use based on the current page's category ID,
parentId="当前分类ID"Get同级或子级分类以形成上下文相关的导航。 - Module-based display on the homepage在首页模板中,通过
moduleId获取不同内容模型下的热门分类,并结合archiveListLabel, display the latest or recommended documents under each category. - Content index page:Build a page that lists all categories, or index categories alphabetically, to help users quickly locate content of interest.
Common Questions (FAQ)
**1. Why